Now is see the error of my ways. I have fixed that and the website is good with the updates applied. I will monitor to see if the issue resolves itself.
This is a MAJOR problem - as in business traumatizing when you have hundreds of order per day coming and in it happens 1/3 of the time. Enough that our credit card processor reached out in concern. Is there a cleaner fix thread that is clear, direct and locked of other messages?
Exposed Clothing, LLC http://exposedclothing.com
Those two are causing an error that doesn't let users to register/login. Website goes straight to some sort of "not found" page but after F5 it works and the user is logged in or in the register process.letxobnav wrote: ↑Thu Jun 04, 2020 8:25 am3) call these functions in register and login controllers
2 function calls for login, giving the current session id to possible old customer items and merging the current guest items
1 function call for register as there cannot be any old customer items so just merging the current guest items
in catalog/controller/checkout/login.php and catalog/controller/account/login.php
just after:add:Code: Select all
unset($this->session->data['guest']);
Code: Select all
// change[662] giving old cart items of the customer the current session id $this->cart->renew_session_id_old_items ($this->customer->getId()); // change[662] assigning the current guest cart items to the customer $this->cart->transfer_items_to_new_customer ($this->customer->getId());
in catalog/controller/checkout/register.php and catalog/controller/account/register.php
just after:add:Code: Select all
unset($this->session->data['guest']);
Code: Select all
// change[662] assigning the current guest cart items to the customer $this->cart->transfer_items_to_new_customer ($this->customer->getId());
That is all.
Error log shows the following /checkout/login.php:
Code: Select all
[05-Nov-2020 08:58:19 America/Argentina/Buenos_Aires] PHP Fatal error: Uncaught Error: Call to undefined method Cart\Cart::renew_session_id_old_items() in /home/c1811017/public_html/catalog/controller/checkout/login.php:64
Stack trace:
#0 /home/c1811017/public_html/storage/modification/system/engine/action.php(79): ControllerCheckoutLogin->save()
#1 /home/c1811017/public_html/catalog/controller/startup/router.php(25): Action->execute(Object(Registry))
#2 /home/c1811017/public_html/storage/modification/system/engine/action.php(79): ControllerStartupRouter->index()
#3 /home/c1811017/public_html/system/engine/router.php(67): Action->execute(Object(Registry))
#4 /home/c1811017/public_html/system/engine/router.php(56): Router->execute(Object(Action))
#5 /home/c1811017/public_html/system/framework.php(165): Router->dispatch(Object(Action), Object(Action))
#6 /home/c1811017/public_html/system/startup.php(104): require_once('/home/c1811017/...')
#7 /home/c1811017/public_html/index.php(26): start('catalog')
#8 {main}
thrown in /home/c1811017/public_html/catalog/controller/checkout/login.php on line 64
Code: Select all
[04-Nov-2020 18:59:41 America/Argentina/Buenos_Aires] PHP Fatal error: Uncaught Error: Call to undefined method Cart\Cart::renew_session_id_old_items() in /home/c1811017/public_html/catalog/controller/account/login.php:56
Stack trace:
#0 /home/c1811017/public_html/storage/modification/system/engine/action.php(79): ControllerAccountLogin->index()
#1 /home/c1811017/public_html/catalog/controller/startup/router.php(25): Action->execute(Object(Registry))
#2 /home/c1811017/public_html/storage/modification/system/engine/action.php(79): ControllerStartupRouter->index()
#3 /home/c1811017/public_html/system/engine/router.php(67): Action->execute(Object(Registry))
#4 /home/c1811017/public_html/system/engine/router.php(56): Router->execute(Object(Action))
#5 /home/c1811017/public_html/system/framework.php(165): Router->dispatch(Object(Action), Object(Action))
#6 /home/c1811017/public_html/system/startup.php(104): require_once('/home/c1811017/...')
#7 /home/c1811017/public_html/index.php(26): start('catalog')
#8 {main}
thrown in /home/c1811017/public_html/catalog/controller/account/login.php on line 56
Code: Select all
[04-Nov-2020 11:51:39 America/Argentina/Buenos_Aires] PHP Fatal error: Uncaught Error: Call to undefined method Cart\Cart::transfer_items_to_new_customer() in /home/c1811017/public_html/catalog/controller/account/register.php:31
Stack trace:
#0 /home/c1811017/public_html/storage/modification/system/engine/action.php(79): ControllerAccountRegister->index()
#1 /home/c1811017/public_html/catalog/controller/startup/router.php(25): Action->execute(Object(Registry))
#2 /home/c1811017/public_html/storage/modification/system/engine/action.php(79): ControllerStartupRouter->index()
#3 /home/c1811017/public_html/system/engine/router.php(67): Action->execute(Object(Registry))
#4 /home/c1811017/public_html/system/engine/router.php(56): Router->execute(Object(Action))
#5 /home/c1811017/public_html/system/framework.php(165): Router->dispatch(Object(Action), Object(Action))
#6 /home/c1811017/public_html/system/startup.php(104): require_once('/home/c1811017/...')
#7 /home/c1811017/public_html/index.php(26): start('catalog')
#8 {main}
thrown in /home/c1811017/public_html/catalog/controller/account/register.php on line 31
[04-Nov-2020 13:40:59 America/Argentina/Buenos_Aires] PHP Fatal error: Uncaught Error: Call to undefined method Cart\Cart::transfer_items_to_new_customer() in /home/c1811017/public_html/catalog/controller/checkout/register.php:240
Stack trace:
#0 /home/c1811017/public_html/storage/modification/system/engine/action.php(79): ControllerCheckoutRegister->save()
#1 /home/c1811017/public_html/catalog/controller/startup/router.php(25): Action->execute(Object(Registry))
#2 /home/c1811017/public_html/storage/modification/system/engine/action.php(79): ControllerStartupRouter->index()
#3 /home/c1811017/public_html/system/engine/router.php(67): Action->execute(Object(Registry))
#4 /home/c1811017/public_html/system/engine/router.php(56): Router->execute(Object(Action))
#5 /home/c1811017/public_html/system/framework.php(165): Router->dispatch(Object(Action), Object(Action))
#6 /home/c1811017/public_html/system/startup.php(104): require_once('/home/c1811017/...')
#7 /home/c1811017/public_html/index.php(26): start('catalog')
#8 {main}
thrown in /home/c1811017/public_html/catalog/controller/checkout/register.php on line 240
Code: Select all
unset($this->session->data['guest']);
// change[662] assigning the current guest cart items to the customer
$this->cart->transfer_items_to_new_customer ($this->customer->getId());
Code: Select all
unset($this->session->data['guest']);
// change[662] assigning the current guest cart items to the customer
$this->cart->transfer_items_to_new_customer ($this->customer->getId());
Code: Select all
unset($this->session->data['guest']);
// change[662] giving old cart items of the customer the current session id
$this->cart->renew_session_id_old_items ($this->customer->getId());
// change[662] assigning the current guest cart items to the customer
$this->cart->transfer_items_to_new_customer ($this->customer->getId());
Code: Select all
unset($this->session->data['guest']);
// change[662] giving old cart items of the customer the current session id
$this->cart->renew_session_id_old_items ($this->customer->getId());
// change[662] assigning the current guest cart items to the customer
$this->cart->transfer_items_to_new_customer ($this->customer->getId());
Thanks!
Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!
I'm having the same issue as the guy that posted while ago, a HTTP 500 ERROR.sw!tch wrote: ↑Sat Nov 07, 2020 9:28 amYou missed step 1 & 2 ..
Note the cart class changes...
viewtopic.php?f=201&t=211273#p789630
I've placed it after "private $data" like you said and it's inside the "__construct"
This is the final result with the modifications you said:
Code: Select all
<?php
namespace Cart;
class Cart {
private $data = array();
public function __construct($registry) {
$this->config = $registry->get('config');
$this->customer = $registry->get('customer');
$this->session = $registry->get('session');
$this->db = $registry->get('db');
$this->tax = $registry->get('tax');
$this->weight = $registry->get('weight');
// 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)");
public function renew_session_id_old_items ($customer_id) {
// We want to change the session ID on all the old items in the customers cart
$sql = "UPDATE " . DB_PREFIX . "cart SET session_id = '" . $this->db->escape($this->session->getId()) . "' WHERE api_id = '0' AND customer_id = '" . (int)$customer_id . "'";
$this->db->query($sql);
}
public function transfer_items_to_new_customer ($customer_id) {
// Once the customer is logged in we want to merge the current guest items with the customer cart and empty the guest cart
$sql = "SELECT * FROM " . DB_PREFIX . "cart WHERE api_id = '0' AND customer_id = '0' AND session_id = '" . $this->db->escape($this->session->getId()) . "'";
$cart_save_query = $this->db->query($sql);
foreach ($cart_save_query->rows as $cart) {
$this->add($cart['product_id'], $cart['quantity'], json_decode($cart['option']), $cart['recurring_id']);
$sql = "DELETE FROM " . DB_PREFIX . "cart WHERE cart_id = '" . (int)$cart['cart_id'] . "'";
$this->db->query($sql);
}
}
}
500 error can be caused by a lot of things. Whats the full error being reported in your server error log?
Maybe PM the member who wrote it for support, clearly the errors being posted are due to improper implementation.
Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!
PHP Parse error: syntax error, unexpected 'public' (T_PUBLIC) in /home/c1811017/public_html/system/library/cart/cart.php on line 17
PHP Parse error: syntax error, unexpected 'public' (T_PUBLIC) in /home/c1811017/public_html/system/library/cart/cart.php on line 19
And there's other errors on login.php and register.php (both catalog/controller/checkout and account).
I've tried to send a PM but I think he's profile is blocked. Maybe I can quote him here? @letxobnav
Any ideas on what's wrong?
Thanks for any help!
Yes, the two functions you added are incorrectly implemented.
Code: Select all
public function transfer_items_to_new_customer ($customer_id) { ..}
public function renew_session_id_old_items ($customer_id) { ..}
Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!
Like this?sw!tch wrote: ↑Wed Nov 18, 2020 12:05 pmYes, the two functions you added are incorrectly implemented.
Your formatting is messed up, these should go into the class not the __construct method.Code: Select all
public function transfer_items_to_new_customer ($customer_id) { ..} public function renew_session_id_old_items ($customer_id) { ..}
Code: Select all
<?php
namespace Cart;
class Cart {
private $data = array();
public function renew_session_id_old_items ($customer_id) {
// We want to change the session ID on all the old items in the customers cart
$sql = "UPDATE " . DB_PREFIX . "cart SET session_id = '" . $this->db->escape($this->session->getId()) . "' WHERE api_id = '0' AND customer_id = '" . (int)$customer_id . "'";
$this->db->query($sql);
}
public function transfer_items_to_new_customer ($customer_id) {
// Once the customer is logged in we want to merge the current guest items with the customer cart and empty the guest cart
$sql = "SELECT * FROM " . DB_PREFIX . "cart WHERE api_id = '0' AND customer_id = '0' AND session_id = '" . $this->db->escape($this->session->getId()) . "'";
$cart_save_query = $this->db->query($sql);
foreach ($cart_save_query->rows as $cart) {
$this->add($cart['product_id'], $cart['quantity'], json_decode($cart['option']), $cart['recurring_id']);
$sql = "DELETE FROM " . DB_PREFIX . "cart WHERE cart_id = '" . (int)$cart['cart_id'] . "'";
$this->db->query($sql);
}
}
public function __construct($registry) {
$this->config = $registry->get('config');
$this->customer = $registry->get('customer');
$this->session = $registry->get('session');
$this->db = $registry->get('db');
$this->tax = $registry->get('tax');
$this->weight = $registry->get('weight');
// 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)");
}
I did all the steps mentioned on this topic.. But it is still duplicating for me... Any idea what else I could do?letxobnav wrote: ↑Wed Jul 24, 2019 8:03 pmthis one is better, previous one had to many deletes ( delete the saved entries all at once and also in the loop).
I use the separate delete query in the loop so I can better trace it (is what is deleted also added) with an error_log statement if needed.Code: Select all
public function transfer_items_to_new_customer ($customer_id) { // Once the customer is logged in we want to update the customers cart $sql = "SELECT * FROM " . DB_PREFIX . "cart WHERE api_id = '0' AND customer_id = '0' AND session_id = '" . $this->db->escape($this->session->getId()) . "'"; $cart_save_query = $this->db->query($sql); foreach ($cart_save_query->rows as $cart) { $sql = "DELETE FROM " . DB_PREFIX . "cart WHERE cart_id = '" . (int)$cart['cart_id'] . "'"; $this->db->query($sql); $this->add($cart['product_id'], $cart['quantity'], json_decode($cart['option']), $cart['recurring_id']); } }
Have you refreshed your modifications and checked that the changes made are applied any files that exist in storage/modification?
You could also try a slightly different version of the workaround.
https://github.com/ADDCreative/opencart ... 7b357a7ce2
ADD Creative wrote: ↑Tue Dec 15, 2020 12:47 amHave you refreshed your modifications and checked that the changes made are applied any files that exist in storage/modification?
You could also try a slightly different version of the workaround.
https://github.com/ADDCreative/opencart ... 7b357a7ce2
Do you mean to go into this path /system/storage/modification... and look for the following? If not, ignore what I put there untill --end--
under the paths:
/system/storage/modification/catalog/controller/account/login.php
/system/storage/modification/catalog/controller/account/register.php
- I do have the files login and register but both dont have any of the code that I added in the other files as mentioned in the post before...
under the path:
/system/storage/modification/catalog/controller/checkout
I only have these files: https://prnt.sc/w306aq
That means I dont have login.php and register.php
and under the path:
/system/storage/modification/system
I dont have a folder nor file called cart...
--end--
Another question is...
Should I add this 'workaround' https://github.com/ADDCreative/opencart ... 7b357a7ce2
that you gave me with those changes I already did or should I go back to how it was and then do this work around?
Thank you
If you don't have any extension that modify those files then you won't find them in storage/modification. If the two files in storage/modification/catalog/controller/account don't have your changes, try refreshing your modifications. In admin go to Extension -> Modifications, then click the blue refresh button in the top right corner.raph7 wrote: ↑Tue Dec 15, 2020 4:36 pmDo you mean to go into this path /system/storage/modification... and look for the following? If not, ignore what I put there untill --end--
under the paths:
/system/storage/modification/catalog/controller/account/login.php
/system/storage/modification/catalog/controller/account/register.php
- I do have the files login and register but both dont have any of the code that I added in the other files as mentioned in the post before...
under the path:
/system/storage/modification/catalog/controller/checkout
I only have these files: https://prnt.sc/w306aq
That means I dont have login.php and register.php
and under the path:
/system/storage/modification/system
I dont have a folder nor file called cart...
--end--
Another question is...
Should I add this 'workaround' https://github.com/ADDCreative/opencart ... 7b357a7ce2
that you gave me with those changes I already did or should I go back to how it was and then do this work around?
Thank you
If you wanted to try the other workaround then you would need to undo the changes you have already made first.
Yeah I just realised I was looking into a different storage... (the one inside my website files and not the one outside)... I found the code there in the 2 files.. What should I do now?ADD Creative wrote: ↑Tue Dec 15, 2020 7:30 pmIf you don't have any extension that modify those files then you won't find them in storage/modification. If the two files in storage/modification/catalog/controller/account don't have your changes, try refreshing your modifications. In admin go to Extension -> Modifications, then click the blue refresh button in the top right corner.raph7 wrote: ↑Tue Dec 15, 2020 4:36 pmDo you mean to go into this path /system/storage/modification... and look for the following? If not, ignore what I put there untill --end--
under the paths:
/system/storage/modification/catalog/controller/account/login.php
/system/storage/modification/catalog/controller/account/register.php
- I do have the files login and register but both dont have any of the code that I added in the other files as mentioned in the post before...
under the path:
/system/storage/modification/catalog/controller/checkout
I only have these files: https://prnt.sc/w306aq
That means I dont have login.php and register.php
and under the path:
/system/storage/modification/system
I dont have a folder nor file called cart...
--end--
Another question is...
Should I add this 'workaround' https://github.com/ADDCreative/opencart ... 7b357a7ce2
that you gave me with those changes I already did or should I go back to how it was and then do this work around?
Thank you
If you wanted to try the other workaround then you would need to undo the changes you have already made first.
If you are sure you have made all the changes and that any files that exist in storage/modification also have the changes, then either there is some sort of mistake with the changes you have made or your issue is caused by something else.
Hi, could anyone please help with the full steps on how to fix this problem?
I have tried this fix: https://github.com/ADDCreative/opencart ... 7b357a7ce2
and it doesn't seem to work - items are still duplicated in the cart at checkout.
I'm getting a lot of customer complaints each day that when they add items to the cart, then go to checkout more items are duplicated and added in their cart without them knowing. The customer then pays and ends up having to open Return Requests.
Any help to fix this would be really appreciated. I added a comment to the bug report too.
I have tried this fix: https://github.com/ADDCreative/opencart ... 7b357a7ce2
and it doesn't seem to work - items are still duplicated in the cart at checkout.
I'm getting a lot of customer complaints each day that when they add items to the cart, then go to checkout more items are duplicated and added in their cart without them knowing. The customer then pays and ends up having to open Return Requests.
Any help to fix this would be really appreciated. I added a comment to the bug report too.
From the comment added to the bug report it sounds like a different issue, as this issue only affect customers who register at checkout. If that is not the case for you I would start a new topic and post more details, such as your OpenCart version, PHP version, theme used, extensions used and the exact steps to recreate the issue.soydemadrid wrote: ↑Mon Sep 04, 2023 7:01 pmHi, could anyone please help with the full steps on how to fix this problem?
I have tried this fix: https://github.com/ADDCreative/opencart ... 7b357a7ce2
and it doesn't seem to work - items are still duplicated in the cart at checkout.
I'm getting a lot of customer complaints each day that when they add items to the cart, then go to checkout more items are duplicated and added in their cart without them knowing. The customer then pays and ends up having to open Return Requests.
Any help to fix this would be really appreciated. I added a comment to the bug report too.
Who is online
Users browsing this forum: No registered users and 3 guests