E-Commerce Suite - Empty Cart
Posted: Wed Feb 17, 2010 9:04 am
HOW TO EMPTY THE WHOLE CART
==========================
You will need to have the CGSimpleSmarty module for this to work
I needed an Empty Cart button in my View Cart template, so at the bottom (but still within the {$formstart}{$formend} tags) I added this button:
Now this will submit the value "empty" when the button is clicked, so then we catch it at the very top of the View Cart template, like this:
That's it, the Button will clear your whole Cart when clicked.
More tips soon...
==========================
You will need to have the CGSimpleSmarty module for this to work
I needed an Empty Cart button in my View Cart template, so at the bottom (but still within the {$formstart}{$formend} tags) I added this button:
Code: Select all
<button type="submit" name="empty_cart" value="empty">Empty Cart</button>
Code: Select all
{*=== $smarty.post.empty_cart is the same as $_POST['empty_cart'] ===*}
{if $smarty.post.empty_cart=="empty"}
{*=== this next line clears the session for Cart ===*}
{session_erase var='cgcart'}
<p>Your cart has been cleared.</p>
{else}
{*=== Cart has no items... ===*}
{if !isset($cartitems) || count($cartitems) == 0 }
<p>Your cart is empty.</p>
{else}
{*=== display all the products... rest of the template goes here ===*}
{*=== .... ===*}
{/if}
{/if}
More tips soon...