Post by sebstore » Fri Jun 21, 2019 9:40 pm

Dear support team,

I received a call from the customer which is using chrome browser and she told me that the items are disappearing from the cart. Do you know if this can be related to cookies or anything else? I am so worried now as we are losing customers and we will go bankrupt soon. I can see this by the results in google analytics when someone is on the cart page and later on is just leaving the page.

Do you have any updated on this problem is there anything that we can do? I spoke with a gold prtner and they are saying this is well-known issue and that they don't have any solution for now...


I am running a new version of opencart 3.0.3.2

New member

Posts

Joined
Tue May 15, 2012 5:25 pm

Post by straightlight » Fri Jun 21, 2019 10:04 pm

sebstore wrote:
Fri Jun 21, 2019 9:40 pm
Dear support team,

I received a call from the customer which is using chrome browser and she told me that the items are disappearing from the cart. Do you know if this can be related to cookies or anything else? I am so worried now as we are losing customers and we will go bankrupt soon. I can see this by the results in google analytics when someone is on the cart page and later on is just leaving the page.

Do you have any updated on this problem is there anything that we can do? I spoke with a gold prtner and they are saying this is well-known issue and that they don't have any solution for now...


I am running a new version of opencart 3.0.3.2
That might be because the gold partner may not as well be informed as anticipated since I did posted a commit on Github regarding products improperly being added to the cart. See if that resolves the issue: https://github.com/opencart/opencart/issues/7377 .

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by sebstore » Sat Jun 22, 2019 2:27 am

Hi Straightlight,

Thank you so much for your reply. Can you just explain me what this code will change? I am not a programer just if you can explain where is the problem in this old part of code?

Best regards,

Sebastian

New member

Posts

Joined
Tue May 15, 2012 5:25 pm

Post by straightlight » Sat Jun 22, 2019 4:34 am

The reason has already been dictated on the Github commit.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by letxobnav » Sat Jun 22, 2019 10:37 am

Disappearing cart items is not the same as not being able to add cart items.

(besides, the INTO part of INSERT INTO is optional in many SQL implementations so it might still work for them)

Of course better to add "INTO" for consistency but I doubt if this is the root cause here.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by straightlight » Sat Jun 22, 2019 8:20 pm

letxobnav wrote:
Sat Jun 22, 2019 10:37 am
Disappearing cart items is not the same as not being able to add cart items.

(besides, the INTO part of INSERT INTO is optional in many SQL implementations so it might still work for them)

Of course better to add "INTO" for consistency but I doubt if this is the root cause here.
This may also be due to the 1 hour interval hardcoded deletion in the system/library/cart/cart.php file. When products are being placed beyond those times, products gets automatically deleted for security purposes since tokens are being created for each cart products.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by letxobnav » Sun Jun 23, 2019 10:42 am

that might be but that is default an hour holding for each individual cart item of a guest.
I can see this by the results in google analytics when someone is on the cart page and later on is just leaving the page.
while this does not say much, I doubt the user spends an hour looking at the cart waiting to see the items go away one by one.

so OP needs to clarify:

1) are items added to the cart ok?
2) do they disappear after and when?

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by straightlight » Sun Jun 23, 2019 7:21 pm

while this does not say much, I doubt the user spends an hour looking at the cart waiting to see the items go away one by one.
That would be presumptuous since it could still happen for a user to test for an hour interval regarding the first product disappearing before noticing the second product, especially for testing purposes. I wonder, however, if the activity event should also track those activities whenever an item gets deleted from the cart ... :ponder:

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by WaxedPerfection » Sun Jun 23, 2019 10:48 pm

When is this going back to as i see you say, "Persistent issue from prior OC versions" on GitHub?

New member

Posts

Joined
Sun Mar 26, 2017 8:23 pm

Post by straightlight » Mon Jun 24, 2019 2:18 am

WaxedPerfection wrote:
Sun Jun 23, 2019 10:48 pm
When is this going back to as i see you say, "Persistent issue from prior OC versions" on GitHub?
How is this relevant to this topic? Please stay on topic.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by letxobnav » Mon Jun 24, 2019 8:07 am

why is it not considered to remove cart items when the guest sessions have expired instead of after an hour from insertion?

That way, while the user remains active, the items in the cart remain and are only removed (and all of them at once, not one by one) when the session is gone (either from the session folder or the session table depending on where you store the session)

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by straightlight » Mon Jun 24, 2019 8:54 pm

Because this topic, for instance, already provides the uncertainty on why individual products are already vanishing without consent. As to what you suggest; to eliminate all products at once for guest users would even less encourage the situation, in this case, because the root cause would still not be identified and the goal on the forum is to be able to identify the root cause as closely as possible to provide a definite solution to conclude their resolutions - not to eliminate the cause.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by WaxedPerfection » Mon Jun 24, 2019 9:12 pm

straightlight wrote:
Mon Jun 24, 2019 2:18 am
WaxedPerfection wrote:
Sun Jun 23, 2019 10:48 pm
When is this going back to as i see you say, "Persistent issue from prior OC versions" on GitHub?
How is this relevant to this topic? Please stay on topic.
the relevent to this topic, is when does this issue go back to 3.0.2.0, or later? im sure your time is better well spent in helping rather than be obstructive.

3.0.3.2 April 9, 2019
3.0.3.1 January 7, 2019
3.0.3.0 January 2, 2019
3.1.0.0_b July 27, 2017
3.0.2.0 July 18, 2017

New member

Posts

Joined
Sun Mar 26, 2017 8:23 pm

Post by straightlight » Mon Jun 24, 2019 9:34 pm

WaxedPerfection wrote:
Mon Jun 24, 2019 9:12 pm
straightlight wrote:
Mon Jun 24, 2019 2:18 am
WaxedPerfection wrote:
Sun Jun 23, 2019 10:48 pm
When is this going back to as i see you say, "Persistent issue from prior OC versions" on GitHub?
How is this relevant to this topic? Please stay on topic.
the relevent to this topic, is when does this issue go back to 3.0.2.0, or later? im sure your time is better well spent in helping rather than be obstructive.

3.0.3.2 April 9, 2019
3.0.3.1 January 7, 2019
3.0.3.0 January 2, 2019
3.1.0.0_b July 27, 2017
3.0.2.0 July 18, 2017
Still, I fail to see how this is related to this topic since you are not addressing the details to the OP's issue as compared to what you claim to see on Github.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by letxobnav » Mon Jun 24, 2019 10:05 pm

You would have to trace it.

1) if it happens, first check if the items are really deleted by checking the DB directly to see if it is a session problem.
2) log the explicit deletions so that if it happens you can check the log to see if it they were deleted this way. You can do this by replacing:

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)");
with this in the cart class.

Code: Select all

		// Remove all the expired carts with no customer ID
		$cart_delete_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "cart WHERE (api_id > '0' OR customer_id = '0') AND date_added < DATE_SUB(NOW(), INTERVAL 1 HOUR)");
		foreach ($cart_delete_query->rows as $cart_entry) {
			error_log('Deleting expired cart entry: '.$cart_entry['cart_id'].' '.$cart_entry['session_id'].' '.$cart_entry['product_id'].' '.$cart_entry['date_added']);
			$this->db->query("DELETE FROM " . DB_PREFIX . "cart WHERE cart_id = '".$cart_entry['cart_id']."'");
		}
Last edited by letxobnav on Mon Jun 24, 2019 10:14 pm, edited 1 time in total.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by straightlight » Mon Jun 24, 2019 10:09 pm

Followed could also help with the total count of products being deleted within the hour of each product intervals:

Code: Select all

// Remove all the expired carts with no customer ID
		$cart_delete_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "cart WHERE (api_id > '0' OR customer_id = '0') AND date_added < DATE_SUB(NOW(), INTERVAL 1 HOUR)");

		$cart_delete_totals = 0;
		
		foreach ($cart_delete_query->rows as $cart_entry) {
			$this->log->write('Deleting expired cart entry: '.$cart_entry['cart_id'].' '.$cart_entry['session_id'].' '.$cart_entry['product_id'].' '.$cart_entry['date_added']);
			$this->db->query("DELETE FROM " . DB_PREFIX . "cart WHERE cart_id = '".$cart_entry['cart_id']."'");
			
			++$cart_delete_totals;
		}
		
		if ($cart_delete_totals) {
		    $this->log->write('Cart deleted totals: ' . $cart_delete_totals . ' product(s).');
		}
		
		// Or
		//if ($cart_delete_query->rows) {
		    //$this->log->write('Cart deleted totals: ' . sizeof($cart_delete_query->rows) . ' product(s).');
		//}

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by letxobnav » Mon Jun 24, 2019 10:18 pm

I think $this->log->write may give an error as that class is not yet constructed, better use error_log.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by letxobnav » Mon Jun 24, 2019 10:22 pm

personally I use this but I use files as session storage.

Code: Select all

		$cart_guest_expire_query = $this->db->query("SELECT cart_id,session_id,product_id FROM " . DB_PREFIX . "cart WHERE (api_id > '0' OR customer_id = '0')");
		foreach ($cart_guest_expire_query->rows as $cart) {
			if (!is_file(DIR_SESSION.'sess_'.$cart['session_id'])) {
				error_log('Deleting expired cart entry: '.$cart['cart_id'].' '.$cart['session_id'].' '.$cart['product_id']);
				$this->db->query("DELETE FROM " . DB_PREFIX . "cart WHERE cart_id = '".$cart['cart_id']."'");
			}
		}

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by straightlight » Mon Jun 24, 2019 10:27 pm

letxobnav wrote:
Mon Jun 24, 2019 10:18 pm
I think $this->log->write may give an error as that class is not yet constructed, better use error_log.
$this->registry is already invoked to that constructor which means instead of using:

Code: Select all

$this->log->write
we could use:

Code: Select all

$this->registry->get('log')->write
Besides, using the shorter version of error_log function would prevent some triggers to be captured as compared to what the core is using originally.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by WaxedPerfection » Mon Jun 24, 2019 11:20 pm

straightlight wrote:
Mon Jun 24, 2019 9:34 pm
WaxedPerfection wrote:
Mon Jun 24, 2019 9:12 pm
straightlight wrote:
Mon Jun 24, 2019 2:18 am


How is this relevant to this topic? Please stay on topic.
the relevent to this topic, is when does this issue go back to 3.0.2.0, or later? im sure your time is better well spent in helping rather than be obstructive.

3.0.3.2 April 9, 2019
3.0.3.1 January 7, 2019
3.0.3.0 January 2, 2019
3.1.0.0_b July 27, 2017
3.0.2.0 July 18, 2017
Still, I fail to see how this is related to this topic since you are not addressing the details to the OP's issue as compared to what you claim to see on Github.
Persistent issue from prior OC versions (except on GitHub file): << This is what you wrote. As im sure you are more than aware, we are on 3.0.3.2 but you say "Persistent issue from prior OC versions" so does that include 3.0.3.1 to 3.0.2.0.

New member

Posts

Joined
Sun Mar 26, 2017 8:23 pm
Who is online

Users browsing this forum: No registered users and 24 guests