// [[orderDetailsInToSESSION]]
if ( empty($_GET['customer']) ) return "no customer account specified";
else {
// sanitize and validate the input type to make sure it's what you are expecting;
$customer = $modx->db->escape($_GET['customer']);
$orderId = $modx->db->escape($_GET['orderId']);
// 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']);
// to put the returned array into a simpler/easier to use array use the following
if (is_array($document_tvs)) {
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']
);
}
}
// if the productId is 219 get the 4 items in the row and add to session array
if ($_SESSION['shoppingCartContents']['productId'] == 219) {
$db_query = $modx->db->SELECT("hummusOne, hummusTwo, mayo, jam", $modx->getFullTableName('customer_order_giftpack_details'), "orderId='" . $orderId . "'");
if ($modx->db->getRecordCount($db_query) > 0) {
while ($row = $modx->db->getRow($db_query)) {
$_SESSION['shoppingCartContents']['hummusOne'] => $row['hummusOne'],
$_SESSION['shoppingCartContents']['hummusTwo'] => $row['hummusTwo'],
$_SESSION['shoppingCartContents']['mayo'] => $row['mayo'],
$_SESSION['shoppingCartContents']['jam'] => $row['jam']
);
}
}
} // end of product219 if
}
This question has been answered by breezer. See the first response.
// if the productId is 219 get the 4 items in the row and add to session array
if ( $_SESSION['shoppingCartContents']['productId'] == 219 ) {
$items = $modx->db->getRow( $modx->db->select( 'hummusOne, hummusTwo, mayo, jam', $modx->getFullTableName( 'customer_order_giftpack_details' ), 'orderId="' . $orderId .'"' ) );
if( $items ){
$_SESSION['shoppingCartContents']['hummusOne'] = $items['hummusOne'];
$_SESSION['shoppingCartContents']['hummusTwo'] = $items['hummusTwo'];
$_SESSION['shoppingCartContents']['mayo'] = $items['mayo'];
$_SESSION['shoppingCartContents']['jam'] = $items['jam'];
}
} // end of product219 if// if the productId is 219 get the 4 items in the row and add to session array
if ( $_SESSION['shoppingCartContents'][0]['productId'] == 219 ) {
$items = $modx->db->getRow( $modx->db->select( 'hummusOne, hummusTwo, mayo, jam', $modx->getFullTableName( 'customer_order_giftpack_details' ), 'orderId="' . $orderId .'"' ) );
if( $items ){
$_SESSION['shoppingCartContents'][0]['hummusOne'] = $items['hummusOne'];
$_SESSION['shoppingCartContents'][0]['hummusTwo'] = $items['hummusTwo'];
$_SESSION['shoppingCartContents'][0]['mayo'] = $items['mayo'];
$_SESSION['shoppingCartContents'][0]['jam'] = $items['jam'];
}
} // end of product219 if

// [[orderDetailsInToSESSION]]
if ( empty( $_GET['customer'] ) ){
return "no customer account specified";
}else{
// sanitize and validate the input type to make sure it's what you are expecting;
$customer = $modx->db->escape( $_GET['customer'] );
$orderId = $modx->db->escape( $_GET['orderId'] );
// get the details from the orderId
$order_details = $modx->db->getRow( $modx->db->select( 'productId, quantity', $modx->getFullTableName( 'customer_order_details' ), 'orderId="' . $orderId .'"' ) );
if( $order_details ){
// get the current prices and names of the products previously ordered
$doc_tvs = $modx->getTemplateVars( array( 'pagetitle', 'price', 'specialPrice' ), 'name', $order_details['productId'] );
// put these details into the session
$_SESSION['shoppingCartContents'][] = Array (
'productId' => $order_details['productId'],
'productTitle' => $doc_tvs['pagetitle'],
'price' => ( !empty( $doc_tvs['specialPrice'] ) ) ? $doc_tvs['specialPrice'] : $doc_tvs['price'],
'quantity' => $order_details['quantity']
);
// if the productId is 219 get the 4 items in the row and add to session array
if( $order_details['productId'] == 219 ){
$items = $modx->db->getRow( $modx->db->select( 'hummusOne, hummusTwo, mayo, jam', $modx->getFullTableName( 'customer_order_giftpack_details' ), 'orderId="' . $orderId .'"' ) );
if( $items ){
$_SESSION['shoppingCartContents'][0]['hummusOne'] = $items['hummusOne'];
$_SESSION['shoppingCartContents'][0]['hummusTwo'] = $items['hummusTwo'];
$_SESSION['shoppingCartContents'][0]['mayo'] = $items['mayo'];
$_SESSION['shoppingCartContents'][0]['jam'] = $items['jam'];
}
}
}
}