Post by labeshops » Wed Dec 30, 2020 12:56 am

Okay, 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.

Running Opencart v3.0.3.2 with multi-stores from https://www.labeshops.com which has links to all my stores.

Image


User avatar
Expert Member

Posts

Joined
Thu Aug 04, 2011 4:41 am
Location - Florida, USA

Post by IP_CAM » Fri Jan 01, 2021 12:23 am

Well, that's most likely not an OC3 Bug, but the result of trying to
make an older Version DB fully work with OC3.
Ernie

I am no longer active at the Forum. Please do NOT send me Personal Mails,
they will no longer be replied to.
My Github OC Site: https://github.com/IP-CAM
4'550 + FREE OC Extensions, on the World's largest Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

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

Post by ADD Creative » Fri Jan 01, 2021 6:18 am

labeshops wrote:
Wed Dec 30, 2020 12:56 am
Okay, 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.
The order ID is assigned here by the database when an order is added.
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.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by JNeuhoff » Fri Jan 01, 2021 11:42 pm

Perhaps multiple sessions, initiated by different customers, all trying to add an order at nearly the same time? Perhaps we need use MySQL locking for cooperating table accesses between sessions. I have seen something similar for other OpenCart MySQL tables when adding rows on rare occasions, and managed to verify the issue when looking at the access logs. In our case it mainly happened when our server was bombarded by high-volume traffic.

Override Engine * Integrated VQMod * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Rich Snippets * Google Tag Manager * Export/Import Tool * SpamBot Buster * Survey Plus


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Zanato » Tue Oct 12, 2021 4:26 pm

@labeshops, did you ever get to the bottom of this? I've had the same thing happen a couple of times recently. It's not unique to PayPal. I wonder, at 45,000 orders, am I outgrowing the database?

New member

Posts

Joined
Fri Oct 04, 2013 4:58 am
Location - Dublin, Ireland

Post by ADD Creative » Tue Oct 12, 2021 7:41 pm

Zanato wrote:
Tue Oct 12, 2021 4:26 pm
@labeshops, did you ever get to the bottom of this? I've had the same thing happen a couple of times recently. It's not unique to PayPal. I wonder, at 45,000 orders, am I outgrowing the database?
What theme and/or checkout extensions are you using?

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by by mona » Tue Oct 12, 2021 9:03 pm

You 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:

Code: Select all

define('AUDIT_TRAIL_CHECKOUT', true);
and write what is posted on checkout to a log in the startup controller like:

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));
		}
	}
in the addOrder function you can log that a new order has been recorded and what the new order id is:

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'));
	}
before:

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
to see how an order is changed from one status to the next.

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.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by straightlight » Tue Oct 12, 2021 11:14 pm

by mona wrote:
Tue Oct 12, 2021 9:03 pm
You 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:

Code: Select all

define('AUDIT_TRAIL_CHECKOUT', true);
and write what is posted on checkout to a log in the startup controller like:

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));
		}
	}
in the addOrder function you can log that a new order has been recorded and what the new order id is:

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'));
	}
before:

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
to see how an order is changed from one status to the next.

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.
These lookups could be used in the Event debug controller file rather than in the startup files.

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 Zanato » Wed Oct 13, 2021 4:36 pm

ADD Creative wrote:
Tue Oct 12, 2021 7:41 pm
What theme and/or checkout extensions are you using?
Journal 3, sure isn't everyone?? ;D

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.

New member

Posts

Joined
Fri Oct 04, 2013 4:58 am
Location - Dublin, Ireland

Post by JNeuhoff » Wed Oct 13, 2021 6:29 pm

Well, the Journal3 one-page checkout has some serious well-known bugs, which was discussed in detail on another forum thread here. Your only option would be to use the standard OpenCart checkout. Chances of finding another 3rd party one-page extension working with the Journal3 framework are slim, most extensions are for OpenCart, not the Journal3 framework which doesn't have a standard-compliant theme.

Override Engine * Integrated VQMod * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Rich Snippets * Google Tag Manager * Export/Import Tool * SpamBot Buster * Survey Plus


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by by mona » Wed Oct 13, 2021 11:52 pm

You are mistaken, rather so many users are here due to issues with that theme gives that impression.

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.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am
Who is online

Users browsing this forum: Bing [Bot] and 5 guests