Post by furrywombat » Sat Apr 11, 2015 12:47 am

I've found that when logging into customer account from the admin panel (module), when I log in to the new customer account, the cart from the account I was previously logged into is placed into the new customer's shopping cart, which is then in turn saved to the database, as if the new customer had placed the other customer's items into their cart.

This can be solved quite simply by modifying system/library/customer.php login function as follows (starting line 53):

from:

Code: Select all

if ($customer_query->num_rows) {
	$this->session->data['customer_id'] = $customer_query->row['customer_id'];	
to:

Code: Select all

if ($customer_query->num_rows) {
	unset($this->session->data['cart']);
	$this->session->data['customer_id'] = $customer_query->row['customer_id'];	
Seems to me like this should be part of the default installation.

FW

User avatar
New member

Posts

Joined
Sat Oct 19, 2013 9:15 pm
Location - Chair

Post by IP_CAM » Sat Apr 11, 2015 1:21 am

Very intelligent solution, tried it on my v.1.5.6.4+ , works flawless,
If a logged in User clicks Logout, with 'collected' items, it clears the box as well.
thank you
Ernie
bigmax.ch

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by furrywombat » Sat Apr 11, 2015 1:32 am

My pleasure, Ernie.

User avatar
New member

Posts

Joined
Sat Oct 19, 2013 9:15 pm
Location - Chair

Post by IP_CAM » Sat Apr 11, 2015 3:24 am

I just made a little VqMod for this, it would enable Users to switch on/off the thing, depending on requirements, without touching the Code, either...

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<modification>
	<id>Clear cart session variable by login/logout</id>
	<version>1.0</version>
	<vqmver>2.4.0</vqmver>
	<author>furrywombat</author>
	<file name="system/library/customer.php">
		<operation>
			<search position="before"><![CDATA[$this->session->data['customer_id'] = $customer_query->row['customer_id'];]]></search>
			<add><![CDATA[unset($this->session->data['cart']);]]></add>
		</operation>
	</file>
</modification>
it may even work! ;D

Ernie

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by furrywombat » Sat Apr 11, 2015 3:41 am

Ernie, that is the exact modification I created in our VQmod folder for our site :) You're a champ (and thanks for the credit)!

FW

User avatar
New member

Posts

Joined
Sat Oct 19, 2013 9:15 pm
Location - Chair

Post by thbr02 » Sat May 09, 2015 12:03 am

It would be nice to use this at Opencart 2.0.2.0. I tried the code but it didn't work. The search code is there alright, but there might be some changes in unsetting the cart code. Is

Code: Select all

unset($this->session->data['cart']);
valid even in opencart 2.0.2.0?

Active Member

Posts

Joined
Wed Jun 22, 2011 10:30 pm
Location - Sweden

Post by IP_CAM » Sat May 09, 2015 2:34 am

possibly now looks like this in OC2:

Code: Select all

unset($this->session->data['customer_id']);
it's the only one available...
Ernie

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by thbr02 » Mon May 11, 2015 12:06 am

Thanks, worked fine!

Active Member

Posts

Joined
Wed Jun 22, 2011 10:30 pm
Location - Sweden

Post by thbr02 » Wed May 20, 2015 3:00 am

I don't know if this is the way to clear the cart in Opencart 2.0.2.0. I thought it worked for awhile but it doesn't. I would be really happy if someone could give me a hint how to fix this issue. When customers get to the last step at checkout the cart is suddenly added with old items from earlier loggins confusing them.

Active Member

Posts

Joined
Wed Jun 22, 2011 10:30 pm
Location - Sweden

Post by thbr02 » Wed May 20, 2015 3:24 am

thbr02 wrote:I don't know if this is the way to clear the cart in Opencart 2.0.2.0. I thought it worked for awhile but it doesn't. I would be really happy if someone could give me a hint how to fix this issue. When customers get to the last step at checkout the cart is suddenly added with old items from earlier loggins confusing them.
Ifound the solution at http://isenselabs.com/posts/disable-sho ... encart-20x. Great! Thank you iSenseLabs.

Active Member

Posts

Joined
Wed Jun 22, 2011 10:30 pm
Location - Sweden
Who is online

Users browsing this forum: No registered users and 7 guests