Link::ToCart());
break;
case SAVE_PRODUCT_FOR_LATER:
ShoppingCart::SaveProductForLater($this->_mItemId);
if (!isset ($_GET['AjaxRequest']))
header('Location: ' . Link::ToCart());
break;
case MOVE_PRODUCT_TO_CART:
ShoppingCart::MoveProductToCart($this->_mItemId);
CHAPTER 13 ?– IMPLEMENTING AJAX FEATURES 420
if (!isset ($_GET['AjaxRequest']))
header('Location: ' . Link::ToCart());
break;
default:
// Do nothing
break;
}
7. Modify the CheckRequest() method of the Link class, in link.php, as highlighted.We don??™t validate the
URL when responding to an AJAX request.
// Redirects to proper URL if not already there
public static function CheckRequest()
{
$proper_url = '';
if (isset ($_GET['Search']) || isset($_GET['SearchResults']) ||
isset ($_GET['CartAction']) || isset ($_GET['AjaxRequest']))
{
return ;
}
8. Open presentation\templates\cart_summary.tpl, and make the changes shown here:
{* cart_summary.tpl *}
{load_presentation_object filename="cart_summary" assign="obj"}
{* Start cart summary *}
Cart Summary
Updating...
{if $obj->mEmptyCart}
Your shopping cart is empty!
{else}
9. Add the following style definition to the tshirtshop.css file from the styles folder:
#updating {
background-color: #ff0000;
border: none;
color: #ffffff;
margin: 2px;
padding: 2px;
visibility: hidden;
position: absolute;
width: 70px;
}
10.
Pages:
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536