Results 1 to 10 of 12

Hybrid View

  1. #1
    Join Date
    May 2006
    Posts
    33
    Plugin Contributions
    0

    Default How to delete products from shopping cart when user session ends

    I want all products from the shopping cart deleted when a user logs out or session ends - irrespective of whether they ordered or not.

    Is there way to do this?

    Thanks!

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    67,426
    Plugin Contributions
    6

    Default Re: How to delete products from shopping cart when user session ends

    It is easier to do this when the customer logs in as you do not know when the customer logs out ... or more specifically, you know the customer is logged out but you don't know who the customer is as the session dies first ...

    So, in the login header where you normally restore the cart you would want to empty it for the customer ...
    /includes/modules/pages/login/header_php.php

    You don't want to just skip the restore as it is getting what is in the database tables so you need to reset it ...

    Changing:
    PHP Code:
            // bof: not require part of contents merge notice
            // restore cart contents
            
    $_SESSION['cart']->restore_contents();
            
    // eof: not require part of contents merge notice 
    to read:
    PHP Code:
            // bof: not require part of contents merge notice
            // restore cart contents
            
    $_SESSION['cart']->restore_contents();
            
    // eof: not require part of contents merge notice
            
    $_SESSION['cart']->reset(true); 
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.3]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...

  3. #3
    Join Date
    May 2006
    Posts
    33
    Plugin Contributions
    0

    Default Re: How to delete products from shopping cart when user session ends

    Thanks... that does seem to reset the existing cart... however all of the 'temporary' visitors cart items are also deleted.

    I just want the previous shopping cart items deleted. So when the visitor shops again and adds items, then logs in he gets only the current products he's added and nothing from the previous session.

    HELP!!

  4. #4
    Join Date
    Jan 2004
    Posts
    60,330
    Blog Entries
    4
    Plugin Contributions
    144

    Default Re: How to delete products from shopping cart when user session ends

    Good point.

    Changing it like this should work:
    PHP Code:
            // restore cart contents
            
    $_SESSION['cart']->restore_contents(); 
    becomes:
    PHP Code:
            $current_cart $_SESSION['cart']->contents;
            
    $_SESSION['cart']->reset(true);
            
    $_SESSION['cart']->contents $current_cart;
            
    $_SESSION['cart']->calculate(); 
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donations always welcome: www.zen-cart.com/donate

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.



  5. #5
    Join Date
    May 2006
    Posts
    33
    Plugin Contributions
    0

    Default Re: How to delete products from shopping cart when user session ends

    Thanks very much! This has solved it!

  6. #6
    Join Date
    Mar 2009
    Posts
    93
    Plugin Contributions
    0

    Default Re: How to delete products from shopping cart when user session ends

    For anybody doing this , when the customer logs out the message says "You have been logged off ....... If you had items in your cart they have been saved , they will be restored when you return"

    Well if you made the changes above thats not the case anymore , you'll need to change the message they see by editing this file:
    - includes/languages/english/logoff.php

 

 

Similar Threads

  1. Update your shopping cart without leaving the products page?
    By bearaman in forum General Questions
    Replies: 26
    Last Post: 11 Apr 2011, 04:00 PM
  2. No Shopping Cart display?
    By SpeedRacer in forum Upgrading from 1.3.x to 1.3.9
    Replies: 8
    Last Post: 1 Mar 2011, 03:05 AM
  3. New Products Not Showing On Main Page
    By julia44 in forum Customization from the Admin
    Replies: 10
    Last Post: 7 Oct 2010, 02:22 PM
  4. 2nd Search always ends on the shopping cart
    By Pedro Fardilha in forum Basic Configuration
    Replies: 0
    Last Post: 8 Feb 2007, 01:35 PM
  5. How do you Add All Products to Empty Shopping Cart Page
    By tinamartinez in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 16 May 2006, 12:59 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •