getElementById('updating').style.visibility = 'hidden';
}
}
CHAPTER 13 ?– IMPLEMENTING AJAX FEATURES 424
Enhancing the Shopping Cart with AJAX
The enhanced shopping cart will use AJAX for updating the shopping cart. When removing products
from the shopping cart, saving products for buying later, or updating product quantities, the
action will happen in the background. During the asynchronous request, an ???Updating...??? label
shows up to indicate visually that the shopping cart is being updated (see Figure 13-4).
Just like with adding products to cart, the shopping cart is updated in a degradable fashion.
If the visitor disables JavaScript, the features will still work but will use the classical form
submit instead of AJAX.
Follow the steps of this exercise to implement your AJAX shopping cart.
AJAXifying the Shopping Cart
1. Let??™s start by modifying the template file, presentation\templates\cart_details.tpl, to call
JavaScript functions on button clicks. Open the file, and apply the highlighted changes:
{* cart_details.tpl *}
{load_presentation_object filename="cart_details" assign="obj"}
Updating...
{if $obj->mIsCartNowEmpty eq 1}
Your shopping cart is empty!
{else}
These are the products in your shopping cart: