Hi,
I want to make cart empty after user logs off. So when user logs in next time, I don't want user to see his last added items in cart.
How can I achieve this in code?
Thanks
Amit
Isn't this already a feature in OpenCart? See the last line of this part of /catalog/controller/account/logout.php
Code: Select all
class ControllerAccountLogout extends Controller {
public function index() {
if ($this->customer->isLogged()) {
$this->customer->logout();
$this->cart->clear();
The Finnish OpenCart Forum
"Real programmers don't document. If it was hard to write, it should be hard to understand."
I tried this but did not work. If user did not complete the order and logs off, in his next log in he sees last added products in cart.Miguelito wrote:Isn't this already a feature in OpenCart? See the last line of this part of /catalog/controller/account/logout.php
Code: Select all
class ControllerAccountLogout extends Controller { public function index() { if ($this->customer->isLogged()) { $this->customer->logout(); $this->cart->clear();
Actually I have two order types: Pickup & Delivery.
Default is Pickup.
But when user selects products for Delivery order type and logs off without completing the order. Then in his next log in he sees last added items under order type Pickup.
That is why I want clear those old items or I can maintain a session for order type along with those items.
But i don't know where make these changes in code?
Default is Pickup.
But when user selects products for Delivery order type and logs off without completing the order. Then in his next log in he sees last added items under order type Pickup.
That is why I want clear those old items or I can maintain a session for order type along with those items.
But i don't know where make these changes in code?
Yea it clears the cart, but the data is saved to the customer. You'd need to remove the serialized insert to the database when a product is added.
1. EDIT: system/library/customer.php
2. FIND AND COMMENT OUT:
1. EDIT: system/library/customer.php
2. FIND AND COMMENT OUT:
Code: Select all
$this->db->query("UPDATE " . DB_PREFIX . "customer SET cart = '" . $this->db->escape(serialize($this->session->data['cart'])) . "', ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "' WHERE customer_id = '" . (int)$this->session->data['customer_id'] . "'");
Who is online
Users browsing this forum: No registered users and 295 guests