Reset Cart after payment

Discussion in 'aMember Pro v.4' started by adrianogaleno, Apr 15, 2013.

  1. adrianogaleno

    adrianogaleno Member

    Joined:
    Jun 26, 2007
    Messages:
    34
    Hello, I would like to reset the cart (0 item) immediately after payment. On the website, there is a bar that shows how many items you have on your card. When you purchase something and pay for it, and you go to aMember's member page, the bar still shows the items that you purchased. If you come back to the cart, it will say that the cart is empty and everything is fine (but you have to go to the cart first). Is there a way that I can do that after successful payment?
    Appreciate any help.
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    What code do you use in order to display number of items in the cart on website?
  3. adrianogaleno

    adrianogaleno Member

    Joined:
    Jun 26, 2007
    Messages:
    34
    The code shows and hides a Shopping Cart bar on the header. Here is the piece of code that I'm having problems with:

    <?php
    $cart = Am_Di::getInstance()->session->cart;
    if($cart && $cart->getItems()){
    // Cart has items;
    echo count($cart->getItems()) . ' item(s) </a>';
    }
    ?>
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Modify your code a little:
    PHP:
    <?php
    $cart 
    Am_Di::getInstance()->session->cart;
    if(
    $cart->getInvoice()->isCompleted())
      
    $cart null;
    if(
    $cart && $cart->getItems()){
    // Cart has items;
    echo count($cart->getItems()) . ' item(s) </a>';
    }
    ?> 
  5. adrianogaleno

    adrianogaleno Member

    Joined:
    Jun 26, 2007
    Messages:
    34
    Yes, it worked. Thank you!

Share This Page