Hi All,
I'd like to change the way the cart works in opencart. Id like a new cart each time a customer logs in. So the same customer could log in from 2 devices at the same time and have a separate cart each. Is this something that is achievable or is the way the cart works to inbedded to be easily changed?
Many thanks
Opencart Version: 3.0.3.9
You can even login with the same customer credentials from two or more different browsers on the same device and have seperate carts if you like.stoikkas@gmail.com wrote: ↑Thu Sep 26, 2024 8:06 pmHi All,
I'd like to change the way the cart works in opencart. Id like a new cart each time a customer logs in. So the same customer could log in from 2 devices at the same time and have a separate cart each. Is this something that is achievable or is the way the cart works to inbedded to be easily changed?
Many thanks
Opencart Version: 3.0.3.9
That's great! How do I set this up? As at the moment both devices/browsers get the same cart.nonnedelectari wrote: ↑Thu Sep 26, 2024 9:27 pmYou can even login with the same customer credentials from two or more different browsers on the same device and have seperate carts if you like.stoikkas@gmail.com wrote: ↑Thu Sep 26, 2024 8:06 pmHi All,
I'd like to change the way the cart works in opencart. Id like a new cart each time a customer logs in. So the same customer could log in from 2 devices at the same time and have a separate cart each. Is this something that is achievable or is the way the cart works to inbedded to be easily changed?
Many thanks
Opencart Version: 3.0.3.9
Many thanks
They get the same cart because OC saves customer carts and restores them and merges them upon login (actually it does this on every page load).stoikkas@gmail.com wrote: ↑Thu Sep 26, 2024 9:35 pmThat's great! How do I set this up? As at the moment both devices/browsers get the same cart.nonnedelectari wrote: ↑Thu Sep 26, 2024 9:27 pmYou can even login with the same customer credentials from two or more different browsers on the same device and have seperate carts if you like.stoikkas@gmail.com wrote: ↑Thu Sep 26, 2024 8:06 pmHi All,
I'd like to change the way the cart works in opencart. Id like a new cart each time a customer logs in. So the same customer could log in from 2 devices at the same time and have a separate cart each. Is this something that is achievable or is the way the cart works to inbedded to be easily changed?
Many thanks
Opencart Version: 3.0.3.9
Many thanks
It only deletes carts from guests after a certain period as in:
in system/library/cart/cart.php
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)");
in system/library/cart/cart.php
comment out:
Code: Select all
if ($this->customer->getId()) {
// We want to change the session ID on all the old items in the customers cart
$this->db->query("UPDATE " . DB_PREFIX . "cart SET session_id = '" . $this->db->escape($this->session->getId()) . "' WHERE api_id = '0' AND customer_id = '" . $this->customer_id . "'");
// Once the customer is logged in we want to update the customers cart
$cart_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "cart WHERE api_id = '0' AND customer_id = '0' AND session_id = '" . $this->db->escape($this->session->getId()) . "'");
foreach ($cart_query->rows as $cart) {
$this->db->query("DELETE FROM " . DB_PREFIX . "cart WHERE cart_id = '" . (int)$cart['cart_id'] . "'");
// The advantage of using $this->add is that it will check if the products already exist and increaser the quantity if necessary.
$this->add($cart['product_id'], $cart['quantity'], json_decode($cart['option']), $cart['recurring_id']);
}
}
Who is online
Users browsing this forum: No registered users and 6 guests