Page 1 of 1

[SOLVED] How to extend customer shopping cart duration?

Posted: Sun Apr 17, 2016 7:18 pm
by JGAN
How can I set the shopping cart for customers who are not logged in to last a week instead of a day?

Re: How to extend customer shopping cart duration?

Posted: Mon Apr 18, 2016 9:20 pm
by oc-extensions
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)");

Re: How to extend customer shopping cart duration?

Posted: Wed Apr 20, 2016 1:07 am
by JGAN
Thanks!!

Re: How to extend customer shopping cart duration?

Posted: Thu Sep 03, 2020 12:29 am
by malam
In opencart 3.0.3.3 the code has changed. Do we have any other solution?

thank you

Re: How to extend customer shopping cart duration?

Posted: Thu Sep 03, 2020 5:09 am
by by mona
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)");