Post by JGAN » Sun Apr 17, 2016 7:18 pm

How can I set the shopping cart for customers who are not logged in to last a week instead of a day?

New member

Posts

Joined
Wed Jan 13, 2016 7:52 pm

Post by oc-extensions » Mon Apr 18, 2016 9:20 pm

Hi,

In last versions of opencart, cart is considered expired if is older than 1 hours and is not set customer_id

Check system/library/cart/cart.php and will find:

Code: Select all

// Remove all the expired carts with no customer ID
		$this->db->query("DELETE FROM " . DB_PREFIX . "cart WHERE customer_id = '0' AND date_added < DATE_SUB(NOW(), INTERVAL 1 HOUR)");
So, if you want to keep this "expired carts" for 7 days then change

Code: Select all

// Remove all the expired carts with no customer ID
		$this->db->query("DELETE FROM " . DB_PREFIX . "cart WHERE customer_id = '0' AND date_added < DATE_SUB(NOW(), INTERVAL 7 DAY)");

Image | Extensions and Custom Development


User avatar
Active Member

Posts

Joined
Fri Jan 06, 2012 11:31 pm

Post by JGAN » Wed Apr 20, 2016 1:07 am

Thanks!!

New member

Posts

Joined
Wed Jan 13, 2016 7:52 pm

Post by malam » Thu Sep 03, 2020 12:29 am

In opencart 3.0.3.3 the code has changed. Do we have any other solution?

thank you

New member

Posts

Joined
Thu Jan 14, 2016 5:30 am

Post by by mona » Thu Sep 03, 2020 5:09 am

Same solution for the different code

Code: Select all

// Remove all the expired carts with no customer ID
		$this->db->query("DELETE FROM " . DB_PREFIX . "cart WHERE (api_id > '0' OR customer_id = '0') AND date_added < DATE_SUB(NOW(), INTERVAL 1 HOUR)");

Code: Select all

// Remove all the expired carts with no customer ID
		$this->db->query("DELETE FROM " . DB_PREFIX . "cart WHERE (api_id > '0' OR customer_id = '0') AND date_added < DATE_SUB(NOW(), INTERVAL 7 DAY)");

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am
Who is online

Users browsing this forum: No registered users and 21 guests