gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
header('Content-Type: text/html');
if (isset ($_GET['CartAction']))
{
$cart_action = $_GET['CartAction'];
if ($cart_action == ADD_PRODUCT)
{
require_once PRESENTATION_DIR . 'cart_details.php';
$cart_details = new CartDetails();
$cart_details->init();
$application->display('cart_summary.tpl');
}
}
else
trigger_error('CartAction not set', E_USER_ERROR);
}
CHAPTER 13 ?– IMPLEMENTING AJAX FEATURES 419
else
{
// Display the page
$application->display('store_front.tpl');
}
// Close database connection
DatabaseHandler::Close();
6. Open presentation\cart_details.php, and make the following changes in the switch block in the
init() method:
if (count($selected_attributes) > 0)
$attributes = implode('/', $selected_attributes) . ': ' .
implode('/', $selected_attribute_values);
ShoppingCart::AddProduct($this->_mItemId, $attributes);
if (!isset ($_GET['AjaxRequest']))
header('Location: ' . $this->mLinkToContinueShopping);
else
return;
break;
case REMOVE_PRODUCT:
ShoppingCart::RemoveProduct($this->_mItemId);
if (!isset ($_GET['AjaxRequest']))
header('Location: ' . Link::ToCart());
break;
case UPDATE_PRODUCTS_QUANTITIES:
for($i = 0; $i < count($_POST['itemId']); $i++)
ShoppingCart::Update($_POST['itemId'][$i], $_POST['quantity'][$i]);
if (!isset ($_GET['AjaxRequest']))
header('Location: ' .
Pages:
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535