I apreciate this is an old thread, but i thouht id add the fix for OC 2.X as i searched around and didnt find anywhere with this information.
To do this in OC 2.x you need to go to System/Library/Cart/Customer.php
Find
Code: Select all
public function login($email, $password, $override = false) {
if ($override) {
$customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(utf8_strtolower($email)) . "' AND status = '1'");
} else {
$customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(utf8_strtolower($email)) . "' AND (password = SHA1(CONCAT(salt, SHA1(CONCAT(salt, SHA1('" . $this->db->escape($password) . "'))))) OR password = '" . $this->db->escape(md5($password)) . "') AND status = '1' AND approved = '1'");
}
Replace with
Code: Select all
public function login($email, $password, $override = false) {
if ($override) {
$customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(utf8_strtolower($email)) . "' AND status = '1'");
} else {
$customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE LOWER(email) = '" . $this->db->escape(utf8_strtolower($email)) . "' AND (password = SHA1(CONCAT(salt, SHA1(CONCAT(salt, SHA1('" . $this->db->escape($password) . "'))))) OR password = '" . $this->db->escape(md5($password)) . "') AND status = '1' AND approved = '1'");
$this->db->query("DELETE FROM " . DB_PREFIX . "cart WHERE customer_id = '" . $customer_query->row['customer_id'] . "'");
}
So if any cart data in the cart table was assigned to a customer after login during a session, but the customer fails to check out, this will clear the cart table of cart data associated with the customer when they next login. This does not clear any cart contents added prior to logining in either.
On side note. i didnt like the way the cart table keeps entries with customer id's of 0, which may never be assigned to a customer in the future so to clear the content i added this to System\Cart\Cart.php
find
Add above
Code: Select all
$this->db->query("DELETE FROM " . DB_PREFIX . "cart WHERE (api_id = '0' AND customer_id = '0') AND date_added < DATE_SUB(NOW(), INTERVAL 1 HOUR)");