<?php
// [[orderDetailsInToSESSION]]
if ( empty($_GET['customer']) ) return "no customer account specified";
else {
// get the details from the orderId
$db_query = $modx->db->select("productId, quantity", $modx->getFullTableName('customer_order_details'), "orderId='" . $_GET['orderId'] . "'");
if ($modx->db->getRecordCount($db_query) > 0) {
while ($row = $modx->db->getRow($db_query)) {
// get the current prices and names of the products previously ordered
$document_tvs = $modx->getTemplateVars(array("pagetitle", "price", "specialPrice"), "name", $row['productId']);
// to put the returned array into a simpler/easier to use array use the following
foreach ($document_tvs as $document_TV) {
$docTVArray[$document_TV['name']] = $document_TV['value'];
}
// put these details into the session
$_SESSION['shoppingCartContents'][] = Array (
'productId' => $row['productId'],
'productTitle' => $docTVArray['pagetitle'],
'price' => ( !empty($docTVArray['specialPrice']) ) ? $docTVArray['specialPrice'] : $docTVArray['price'],
'quantity' => $row['quantity']
);
}
}
}
?>This question has been answered by sottwell. See the first response.
if you can.<?php
// [[orderDetailsInToSESSION]]
if ( empty($_GET['customer']) ) return "no customer account specified";
else {
// get the details from the orderId
$db_query = $modx->db->select("productId, quantity", $modx->getFullTableName('customer_order_details'), "orderId='" . $_GET['orderId'] . "'");
if ($modx->db->getRecordCount($db_query) > 0) {
while ($row = $modx->db->getRow($db_query)) {
// get the current prices and names of the products previously ordered
$document_tvs = $modx->getTemplateVars(array("productName", "price", "specialPrice"), "name", $row['productId']);
// to put the returned array into a simpler/easier to use array use the following
foreach ($document_tvs as $document_TV) {
$docTVArray[$document_TV['name']] = $document_TV['value'];
}
// put these details into the session
$_SESSION['shoppingCartContents'][] = Array (
'productId' => $row['productId'],
'productTitle' => $docTVArray['productName'],
'price' => ( !empty($docTVArray['specialPrice']) ) ? $docTVArray['specialPrice'] : $docTVArray['price'],
'quantity' => $row['quantity']
);
}
}
}
?><?php
// [[orderDetailsInToSESSION]]
if ( empty($_GET['customer']) ) return "no customer account specified";
else {
// please sanitize and preferably validate the input type to make sure it's what you are expecting; never, ever trust "foreign" input around your database - you could get an SQL injection exploit
$orderId = $modx->db->escape($_GET['customer']);
// get the details from the orderId
$db_query = $modx->db->select("productId, quantity", $modx->getFullTableName('customer_order_details'), "orderId='" . $orderId . "'");
if ($modx->db->getRecordCount($db_query) > 0) {
while ($row = $modx->db->getRow($db_query)) {
// get the current prices and names of the products previously ordered
$document_tvs = $modx->getTemplateVars(array("pagetitle", "price", "specialPrice"), "name", $row['productId']);
echo "<pre>";
print_r($document_tvs);
echo "</pre>";
}
}
}$customer = $modx->db->escape($_GET['customer']); $orderId = $modx->db->escape($_GET['orderId']);