Page 1 of 1

E-Commerce Suite - Empty Cart

Posted: Wed Feb 17, 2010 9:04 am
by hexdj
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:

Code: Select all

<button type="submit" name="empty_cart" value="empty">Empty Cart</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:

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}
That's it, the Button will clear your whole Cart when clicked.


More tips soon...

Re: E-Commerce Suite - Empty Cart

Posted: Fri Jul 30, 2010 7:30 pm
by inyerface
Very cool. 3 thumbs up for sure!