I am using 3.0.3.2 and the paypal commerce platform. I am getting most orders correctly, but at least 3 times now, an old opencart order id is suddenly assigned to the order when it is processed thru payments so the order never appears in opencart - not under missing orders or the order id. But the payment went thru paypal and shows the old order id in the paypal transaction details!!! I cannot figure out any reason for this glitch other than a possible bug in how the order ids are assigned??? I am currently in 24xxx order ids and one showed up as 21xxx, another as 20xxx and the third I have found so far as 22xxx number ranges - not even sequential!!! These were across different dates too, so not something glitching on a date.
Any idea how this could happen and how to correct it? I only found these when the customers called wondering where their order was - short of checking every single payment in paypal which I don't have time to do since I get a LOT of orders, not sure how to even find them!!
I have no mods that do anything with order ids or anything I can think of that might affect it. I looked at error logs from the dates of the last one and nada. I don't have logs from the dates of the first 2.
Running Opencart v3.0.3.2 with multi-stores and the default template from https://www.labeshops.com which has links to all my stores.
make an older Version DB fully work with OC3.
Ernie
My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.
The order ID is assigned here by the database when an order is added.labeshops wrote: ↑Wed Dec 30, 2020 12:56 amOkay, this is a very strange bug - first time, I thought it just a weird 1x glitch, but I have found at least 3 instances.
I am using 3.0.3.2 and the paypal commerce platform. I am getting most orders correctly, but at least 3 times now, an old opencart order id is suddenly assigned to the order when it is processed thru payments so the order never appears in opencart - not under missing orders or the order id. But the payment went thru paypal and shows the old order id in the paypal transaction details!!! I cannot figure out any reason for this glitch other than a possible bug in how the order ids are assigned??? I am currently in 24xxx order ids and one showed up as 21xxx, another as 20xxx and the third I have found so far as 22xxx number ranges - not even sequential!!! These were across different dates too, so not something glitching on a date.
Any idea how this could happen and how to correct it? I only found these when the customers called wondering where their order was - short of checking every single payment in paypal which I don't have time to do since I get a LOT of orders, not sure how to even find them!!
I have no mods that do anything with order ids or anything I can think of that might affect it. I looked at error logs from the dates of the last one and nada. I don't have logs from the dates of the first 2.
https://github.com/opencart/opencart/bl ... .php#L4-L6
So for the order ID to be wrong it could be a problem with the database generating the next ID or the result of an extension, theme or payment module changing the way orders are added to the database.
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
What theme and/or checkout extensions are you using?
in config.php you can add a switch:
Code: Select all
define('AUDIT_TRAIL_CHECKOUT', true);
Code: Select all
$this->registry->set('checkoutlog', new Log('checkoutlog.log'));
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// log post data to checkout except the cart
if (!empty($this->request->post) && strstr($_SERVER['REQUEST_URI'],'checkout/') && !stristr($_SERVER['REQUEST_URI'],'checkout/cart')) {
if (AUDIT_TRAIL_CHECKOUT) $this->checkoutlog->write($_SERVER['REMOTE_ADDR'].' POST on '.$_SERVER['REQUEST_URI'].' '.print_r($this->request->post,true));
}
}
Code: Select all
// log the order recording and order id
if (AUDIT_TRAIL_CHECKOUT) $this->checkoutlog->write($_SERVER['REMOTE_ADDR'].' New Order recorded with id: '.$order_id);
before:
[code]
return $order_id;
In your paypal controller you can log what is being send to and received from paypal (pp standard already has a debug setting for the callback):
Code: Select all
// log what data we actually send to paypal
if (AUDIT_TRAIL_CHECKOUT) $this->checkoutlog->write($_SERVER['REMOTE_ADDR'].' Data send to PayPal for order : '.$this->session->data['order_id'].' '.print_r($data,true));
before:
[code]
return $this->load->view('extension/payment/pp_standard', $data);
In the paypal callback function you can add:
Code: Select all
// log the order history update
if (AUDIT_TRAIL_CHECKOUT) {
// get the order status name from the id
$csql = "select name from ".DB_PREFIX."order_status where order_status_id = ".$order_status_id." and language_id = ".$this->config->get('config_language_id');
$results = $this->db->query($csql);
$status = (!empty($results->row['name']) ? $results->row['name'] : $order_status_id);
$this->checkoutlog->write($_SERVER['REMOTE_ADDR'].' PayPal - Updating order : '.$order_id.' to status: '.$status);
}
before:
[code]
$this->model_checkout_order->addOrderHistory($order_id, $order_status_id);
In the bank transfer payment controller or any of the others you can record the order history change:
Code: Select all
// log the order history update
if (AUDIT_TRAIL_CHECKOUT) {
// get the order status name from the id
$csql = "select name from ".DB_PREFIX."order_status where order_status_id = ".$this->config->get('payment_bank_transfer_order_status_id')." and language_id = ".$this->config->get('config_language_id');
$results = $this->db->query($csql);
$status = (!empty($results->row['name']) ? $results->row['name'] : $this->config->get('payment_bank_transfer_order_status_id'));
$this->checkoutlog->write($_SERVER['REMOTE_ADDR'].' Bank Transfer - Updating order : '.$this->session->data['order_id'].' to status: '.$this->config->get('payment_bank_transfer_order_status_id'));
}
Code: Select all
$this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('payment_bank_transfer_order_status_id'), $comment, true);
in the addOrderHistory function of model checkout/order.php you can even add:
Code: Select all
if (AUDIT_TRAIL_CHECKOUT) {
$csql = "select name from ".DB_PREFIX."order_status where order_status_id = ".$order_info['order_status_id']." and language_id = ".$this->config->get('config_language_id');
$results = $this->db->query($csql);
$fromstatus = (!empty($results->row['name']) ? $results->row['name'] : $order_status_id);
$csql = "select name from ".DB_PREFIX."order_status where order_status_id = ".$order_status_id." and language_id = ".$this->config->get('config_language_id');
$results = $this->db->query($csql);
$tostatus = (!empty($results->row['name']) ? $results->row['name'] : $order_status_id);
$this->checkoutlog->write($_SERVER['REMOTE_ADDR'].' Order History: Order '.$order_id.' moved from status '.$fromstatus.' to '.$tostatus);
}
before:
Code: Select all
// If current order status is not processing or complete but new status is processing or complete then commence completing the order
you can add these conditional log entries to various vital functions along the checkout path (methods, payment gateways, etc) so, when activated by a single switch, you have a clear chronology of the processing of the orders.
Without it you know only the result and when things go wrong can only speculate as to the cause.
DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.
https://www.youtube.com/watch?v=zXIxDoCRc84
These lookups could be used in the Event debug controller file rather than in the startup files.by mona wrote: ↑Tue Oct 12, 2021 9:03 pmYou could add some audit trail to your most important activities and log what is happening during checkout processing.
in config.php you can add a switch:and write what is posted on checkout to a log in the startup controller like:Code: Select all
define('AUDIT_TRAIL_CHECKOUT', true);
in the addOrder function you can log that a new order has been recorded and what the new order id is:Code: Select all
$this->registry->set('checkoutlog', new Log('checkoutlog.log')); if ($_SERVER['REQUEST_METHOD'] == 'POST') { // log post data to checkout except the cart if (!empty($this->request->post) && strstr($_SERVER['REQUEST_URI'],'checkout/') && !stristr($_SERVER['REQUEST_URI'],'checkout/cart')) { if (AUDIT_TRAIL_CHECKOUT) $this->checkoutlog->write($_SERVER['REMOTE_ADDR'].' POST on '.$_SERVER['REQUEST_URI'].' '.print_r($this->request->post,true)); } }
Code: Select all
// log the order recording and order id if (AUDIT_TRAIL_CHECKOUT) $this->checkoutlog->write($_SERVER['REMOTE_ADDR'].' New Order recorded with id: '.$order_id); before: [code] return $order_id;
In your paypal controller you can log what is being send to and received from paypal (pp standard already has a debug setting for the callback):Code: Select all
// log what data we actually send to paypal if (AUDIT_TRAIL_CHECKOUT) $this->checkoutlog->write($_SERVER['REMOTE_ADDR'].' Data send to PayPal for order : '.$this->session->data['order_id'].' '.print_r($data,true)); before: [code] return $this->load->view('extension/payment/pp_standard', $data);
In the paypal callback function you can add:Code: Select all
// log the order history update if (AUDIT_TRAIL_CHECKOUT) { // get the order status name from the id $csql = "select name from ".DB_PREFIX."order_status where order_status_id = ".$order_status_id." and language_id = ".$this->config->get('config_language_id'); $results = $this->db->query($csql); $status = (!empty($results->row['name']) ? $results->row['name'] : $order_status_id); $this->checkoutlog->write($_SERVER['REMOTE_ADDR'].' PayPal - Updating order : '.$order_id.' to status: '.$status); } before: [code] $this->model_checkout_order->addOrderHistory($order_id, $order_status_id);
In the bank transfer payment controller or any of the others you can record the order history change:before:Code: Select all
// log the order history update if (AUDIT_TRAIL_CHECKOUT) { // get the order status name from the id $csql = "select name from ".DB_PREFIX."order_status where order_status_id = ".$this->config->get('payment_bank_transfer_order_status_id')." and language_id = ".$this->config->get('config_language_id'); $results = $this->db->query($csql); $status = (!empty($results->row['name']) ? $results->row['name'] : $this->config->get('payment_bank_transfer_order_status_id')); $this->checkoutlog->write($_SERVER['REMOTE_ADDR'].' Bank Transfer - Updating order : '.$this->session->data['order_id'].' to status: '.$this->config->get('payment_bank_transfer_order_status_id')); }
Code: Select all
$this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('payment_bank_transfer_order_status_id'), $comment, true);
in the addOrderHistory function of model checkout/order.php you can even add:Code: Select all
if (AUDIT_TRAIL_CHECKOUT) { $csql = "select name from ".DB_PREFIX."order_status where order_status_id = ".$order_info['order_status_id']." and language_id = ".$this->config->get('config_language_id'); $results = $this->db->query($csql); $fromstatus = (!empty($results->row['name']) ? $results->row['name'] : $order_status_id); $csql = "select name from ".DB_PREFIX."order_status where order_status_id = ".$order_status_id." and language_id = ".$this->config->get('config_language_id'); $results = $this->db->query($csql); $tostatus = (!empty($results->row['name']) ? $results->row['name'] : $order_status_id); $this->checkoutlog->write($_SERVER['REMOTE_ADDR'].' Order History: Order '.$order_id.' moved from status '.$fromstatus.' to '.$tostatus); }
before:to see how an order is changed from one status to the next.Code: Select all
// If current order status is not processing or complete but new status is processing or complete then commence completing the order
you can add these conditional log entries to various vital functions along the checkout path (methods, payment gateways, etc) so, when activated by a single switch, you have a clear chronology of the processing of the orders.
Without it you know only the result and when things go wrong can only speculate as to the cause.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Journal 3, sure isn't everyone??
Thanks for the other replies too, I'll try adding the log function and see if I can get any info. The problem is it's only ever happened twice and there's been hundreds of orders since it last happened. I could be waiting months for it to happen again.
I'll give Journal3 a shout and see if they know anything about it too.
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.
https://www.youtube.com/watch?v=zXIxDoCRc84
I am experiencing the same (old customers order being used and replaced by new one, i.e. the old one is rewritten).
Thanks!
Matus
Users browsing this forum: No registered users and 95 guests