If this is your first visit, check our documentation. To post, register or login.
Forums / Managing Customers and Orders / Duplicate Orders/Order Confirmation

Duplicate Orders/Order Confirmation

Started by beer_man on 9 Jul 2007, 11:39 AM · Views: 65,660

Results 101 to 120 of 131
25 Sep 2012, 2:49 AM
#101
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Duplicate Orders/Order Confirmation

The common term used for the theory you describe is a "race condition" where two or more similar events fire at the same time and are treated independently instead of serially.

It's very simple to solve any "duplicate" problem caused when using Website Payments Standard module: Simply remove that module and use the more reliable Express Checkout module. Then there will be no race-conditions on ipn_main_handler causing duplicates.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

27 Sep 2012, 12:50 AM
#102
gelgel avatar

gelgel

New Zenner

Join Date:
Sep 2012
Posts:
2
Plugin Contributions:
0

Re: Duplicate Orders/Order Confirmation

Thank you DrByte
but I prefer to Fix the Problem instead Switching module.

ok this class will let us to process multiple txn_id's Serial so there wont be "race condition" any more. if it succeed i will share the result.

class process_filelock {
	protected $process_id;
	protected $category;
	protected $additional="Dummy Text";
	protected $process_unq_id;
	protected $active_status_code='ACTIVE';
	protected $file_path='';
	protected $fp;
	
	function __construct() {
		$this->set_file_path();
		register_shutdown_function(array(&$this, "unlock"));
	}	
	function get_file_path(){
		return $this->file_path;
	}
	protected function get_file() {
		return $this->file_path.$this->category.'_'.$this->process_id.'.lock';
	}
	protected function set_file_path() {
		if(defined(DIR_FS_CATALOG)){
			$this->file_path=DIR_FS_CATALOG.'cache/';
		}else{
			$this->file_path='cache/';
		}
		if (!is_dir($this->file_path)) {
			mkdir($this->file_path,0700,true);
		}
	}

	function lock($process_id,$category='DEFAULT',$additional=''){
		$this->process_id=$process_id;
		$this->category=$category;
		$this->additional=$additional;
		
		$file=$this->get_file();
		$this->fp = fopen( $file,"a"); // open it for WRITING ("w") 
		if (!$this->fp){
			return false;
		}
		if (flock($this->fp, LOCK_EX)) {
		// do your file writes here
		fwrite($this->fp, date("H:i:s", time())." Lock defined on file. \n".$this->additional."\n");
		return true;
	    } else {
	    	return false;
	    }
	}

	protected function __destruct() {
		$this->unlock();
	}

	function unlock() {
		fwrite($this->fp, date("H:i:s", time())." Lock Released on file. \n");
		$ret=flock($this->fp, LOCK_UN);
		fclose($this->fp);
		return $ret;
	}
}
class process_paypal_filelock extends process_filelock{
	protected function set_file_path() {if(defined(DIR_FS_CATALOG)){
			$this->file_path=DIR_FS_CATALOG.'includes/modules/payment/paypal/locks/';
		}else{			
			$this->file_path='includes/modules/payment/paypal/locks/';
		}
		if (!is_dir($this->file_path)) {
			mkdir($this->file_path,0700,true);
		}
	}
}

insert following code after following line
require('includes/application_top.php');

require('includes/classes/process_lock.php');
$lock=new process_paypal_filelock();
$lock->lock($_POST['txn_id'],"PAYPAL_IPN","Note");
27 Sep 2012, 2:57 AM
#103
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Duplicate Orders/Order Confirmation

But ... if you're really using the Website Payments Standard module, then you have MANY OTHER problems too.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

13 Jan 2013, 12:27 AM
#104
friedrich72 avatar

friedrich72

New Zenner

Join Date:
May 2009
Location:
Kansas
Posts:
39
Plugin Contributions:
0

Re: Duplicate Orders/Order Confirmation

alex42:

Quick fix:
Remove the javascript function in

includes/templates/[TEMPLATE]/templates/tpl_checkout_confirmation_default.php

> search line 174, and remove the 
>    ```
onsubmit="submitonce();"

part.
Doing so, you will lose the functionality, that the user cannot click twice on the submit button, but orders are not doubled any more.

We are having duplicate orders also.
I tried the above solution but we just received a duplicate after weeks without seeing one. Could have been a double click this time since I removed that prevention.
Duplicates have been going on for several months and appear to be totally random.
We are not using paypal at all we are using CEON manual card. We are also using Edit Orders module among others. And Zen Cart 1.3.9h.
The only thing that explains the randomness is that it's browser specific as some have mentioned. IE6 or something...

We are at our wits end to figure this out. Every time it happens we have to tell the customer not to worry...etc.

1 Jul 2013, 9:40 AM
#105
jamie_prismart_com avatar

jamie_prismart_com

New Zenner

Join Date:
Oct 2004
Posts:
34
Plugin Contributions:
0

Re: Duplicate Orders/Order Confirmation

I have the same problem with duplicate orders. they always occur when an order is made (nothing to do with back to back issues).

Jamie

1 Jul 2013, 6:19 PM
#106
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Duplicate Orders/Order Confirmation

[email protected]:

I have the same problem with duplicate orders. they always occur when an order is made (nothing to do with back to back issues).

So ... how about sharing some info about your site? like ZC version and the affected payment module at the very least? Click Reply and then read the questions in the Posting Tips dialog shown above the reply box.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

2 Jul 2013, 5:17 PM
#107
jamie_prismart_com avatar

jamie_prismart_com

New Zenner

Join Date:
Oct 2004
Posts:
34
Plugin Contributions:
0

Re: Duplicate Orders/Order Confirmation

Good point -

Ceon Sage Pay Server v1.2.2 , Database Version: 1.2.2

Zen-Cart: v1.3.9h
Database: MySQL 5.1.70-cll
HTTP Server: Apache/2.2.24 (Unix)
mod_ssl/2.2.24 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1
PHP Version: 5.2.17 (Zend: 2.2.0)
PHP Memory Limit: 128M
PHP Safe Mode: Off
PHP File Uploads: On
Max Size: 10M
POST Max Size: 8M
Database Data Size: 2,269 kB
Database Index Size: 1,324 kB

Jamie

4 Sep 2013, 7:58 AM
#108
dgent avatar

dgent

Totally Zenned

Join Date:
Nov 2009
Location:
UK
Posts:
1,117
Plugin Contributions:
0

Re: Duplicate Orders/Order Confirmation

I know why this happens on Paypal, its actually caused by the customer. I did a test transaction the other day, and on the page after you have confirmed the payment on the Paypal side, it says something like 'you will be returned to {your website} in 10 seconds, if your page doesnt load click here'.

Basically if you click that link more than once every couple of seconds it will duplicate orders as many times as you click it.

9 Sep 2013, 9:42 PM
#109
evenangelsdie avatar

evenangelsdie

New Zenner

Join Date:
Oct 2008
Posts:
31
Plugin Contributions:
0

Re: Duplicate Orders/Order Confirmation

So, I was having this same issue for the longest time and none of the posts I could find on here were of any help. Last night, I received 36 (!!!) duplicates of the same order and decided I had enough of this nonsense. About 5 minutes after the orders were duplicated, I also received a very nasty message (sent through my zen cart contact form) from the customer who had thought she was charged a whole bunch of times (she wasn't, just once but she got 36 order confirmation emails as well so was alarmed). ANYWAYS I finally figured out what the issue was because it just so happened that her contact form message was also sent to me NUMEROUS times. It then crossed my mind that this could be an email issue.

I did a bunch of test orders and noticed that after clicking my "confirm order" button, the site was SOOOOOOO slow. I'm pretty sure that either:
a) the customers just get fed up and press the button a bunch of times if it's taking too long to connect to the mail server as it looks like the website isn't doing anything.
b) there is an issue with my mail server and it continuously loops or something while trying to submit the order, causing it to go through too many times.

I decided to change the email settings from PHP to sendmail and voila! My checkout was much faster which resulted in only having to press the Confirm Order button once, which resulted in no more duplicate orders.

So long story short, try changing your email settings.

10 Sep 2013, 8:43 AM
#110
dgent avatar

dgent

Totally Zenned

Join Date:
Nov 2009
Location:
UK
Posts:
1,117
Plugin Contributions:
0

Re: Duplicate Orders/Order Confirmation

evenangelsdie:

I did a bunch of test orders and noticed that after clicking my "confirm order" button, the site was SOOOOOOO slow. I'm pretty sure that either:
a) the customers just get fed up and press the button a bunch of times if it's taking too long to connect to the mail server as it looks like the website isn't doing anything.
b) there is an issue with my mail server and it continuously loops or something while trying to submit the order, causing it to go through too many times.

Yes, that kind of confirms what I found above, the user doing it.

18 Sep 2013, 3:06 PM
#111
evenangelsdie avatar

evenangelsdie

New Zenner

Join Date:
Oct 2008
Posts:
31
Plugin Contributions:
0

Re: Duplicate Orders/Order Confirmation

I spoke too soon. :
Issue is back. I haven't had 36 duplicates in a row though, just doubles. Would love if this could be sorted out for good as it's frustrating having to manually delete the duplicates in the back end to make my accounting balance.

18 Sep 2013, 3:17 PM
#112
dgent avatar

dgent

Totally Zenned

Join Date:
Nov 2009
Location:
UK
Posts:
1,117
Plugin Contributions:
0

Re: Duplicate Orders/Order Confirmation

evenangelsdie:

I spoke too soon. :
Issue is back. I haven't had 36 duplicates in a row though, just doubles. Would love if this could be sorted out for good as it's frustrating having to manually delete the duplicates in the back end to make my accounting balance.

As I said, if the person clicks the return to site link twice quickly, it will make two orders. Try it yourself.

24 Sep 2013, 1:30 PM
#113
evenangelsdie avatar

evenangelsdie

New Zenner

Join Date:
Oct 2008
Posts:
31
Plugin Contributions:
0

Re: Duplicate Orders/Order Confirmation

Yes I've already read your post about this, but am still hoping for a solution that hasn't been found. My email solution fixed the multiples of orders, but it still looks like I'm stuck with the duplicates from the PayPal user issue. There has to be a way to fix this on the zen cart end...? Such as not registering a second order with the same PayPal transaction id or something?

26 Sep 2013, 7:33 PM
#114
kdoronzio avatar

kdoronzio

New Zenner

Join Date:
Jun 2004
Posts:
4
Plugin Contributions:
0

Re: Duplicate Orders/Order Confirmation

I'm not sure this is the same issue everyone here is having, but I believe I found the solution to this problem for us.

The distinction seems to be CSS buttons versus image buttons. We use CSS buttons. Apparently, CSS submit buttons don't get a name or id like their image counterparts do. As a result, the submitonce() code doesn't work, since it references an element with the id "btn_submit", which doesn't exist.

Apparently there is a bug that resulted in leaving this capability out. We've confirmed this bug existed in 1.38a and 1.51. We're using 1.51. I don't know the root of this bug, and why it was never enabled. As a result, I don't know if my fix will cause problems that I haven't seen yet. It seems innocuous enough.
reference: http://www.zen-cart.com/showthread.php?185671-zen_image_submit

Our fix was to change the function for zen_image_submit() so that CSS buttons inherit the parameters variable just like the image counterparts do.

In /includes/functions/html_output.php
Line near 268 reads:
if (strtolower(IMAGE_USE_CSS_BUTTONS) == 'yes' && strlen($alt)<30) return zenCssButton($image, $alt, 'submit', $sec_class /, $parameters = ''/ );

Remove the comments and the = '' so it reads:
if (strtolower(IMAGE_USE_CSS_BUTTONS) == 'yes' && strlen($alt)<30) return zenCssButton($image, $alt, 'submit', $sec_class , $parameters );

That's it.

Again, I don't know repercussions, but a quick run through our site seems OK. And this issue seems to be fixed, for us at least.

26 Mar 2014, 12:38 PM
#115
kamion avatar

kamion

New Zenner

Join Date:
Mar 2011
Posts:
93
Plugin Contributions:
0

Re: Duplicate Orders/Order Confirmation

dgent:

I know why this happens on Paypal, its actually caused by the customer. I did a test transaction the other day, and on the page after you have confirmed the payment on the Paypal side, it says something like 'you will be returned to {your website} in 10 seconds, if your page doesnt load click here'.

Basically if you click that link more than once every couple of seconds it will duplicate orders as many times as you click it.

Is there a way to detect this and debouncing/preventing it?

30 Mar 2014, 1:58 PM
#116
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Duplicate Orders/Order Confirmation

kamion:

Is there a way to detect this and debouncing/preventing it?
Yes: Use PayPal Express Checkout instead of PayPal Standard!

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

30 Mar 2014, 3:34 PM
#117
kamion avatar

kamion

New Zenner

Join Date:
Mar 2011
Posts:
93
Plugin Contributions:
0

Re: Duplicate Orders/Order Confirmation

DrByte:

Yes: Use PayPal Express Checkout instead of PayPal Standard!

Sorry, I'm using a different payment gateway. Is there code in ZenCart's Paypal Express Checkout module that does the debouncing which I can integrate to my own payment module?

30 Mar 2014, 8:19 PM
#118
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Duplicate Orders/Order Confirmation

Not sure what what "debouncing" you need. You've given no relevant information to go on, including your ZC version, which payment module you're using, and what specific actual problems you're having.
This thread has 114 posts in it, all discussing various forms of duplicate orders, along with various solutions. Which ones have you tried? And what was the result?

The latest version of Zen Cart includes protections to prevent customers from clicking the "confirm" page in your store multiple times, thus preventing multiple submissions and thus duplicate orders when using payment modules which collect card details directly on your site.

If you're getting duplicates from another payment provider where payment is handled on their site, then you probably need to sort out the duplicates problem with them.
But, in the absence of information relevant to your specific scenario, it's really hard to give you a useful answer.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

3 Apr 2014, 5:45 AM
#119
kamion avatar

kamion

New Zenner

Join Date:
Mar 2011
Posts:
93
Plugin Contributions:
0

Re: Duplicate Orders/Order Confirmation

DrByte:

If you're getting duplicates from another payment provider where payment is handled on their site, then you probably need to sort out the duplicates problem with them.
But, in the absence of information relevant to your specific scenario, it's really hard to give you a useful answer.

Thanks for the response, DrByte. I'm on 1.39h but just on the cusp of completing my upgrade to 1.51. We are using a payment gateway to handle our credit card payments. So it would be as you said above. I suspect customers click twice to return from the external payment gateway, as the payment gateway only registers one payment, but two orders are created on our website.

DrByte, what do you think of modifying the payment module "before_process()" function to check if the same payment ID (from the payment gateway) already has been processed, and if it has, straight away redirect to FILENAME_CHECKOUT_SUCCESS?

24 Jun 2014, 8:14 PM
#120
karinvd avatar

karinvd

New Zenner

Join Date:
Nov 2012
Location:
Utrecht, Nederland
Posts:
43
Plugin Contributions:
0

Re: Duplicate Orders/Order Confirmation

kdoronzio:

I'm not sure this is the same issue everyone here is having, but I believe I found the solution to this problem for us.

The distinction seems to be CSS buttons versus image buttons. We use CSS buttons. Apparently, CSS submit buttons don't get a name or id like their image counterparts do. As a result, the submitonce() code doesn't work, since it references an element with the id "btn_submit", which doesn't exist.

Apparently there is a bug that resulted in leaving this capability out. We've confirmed this bug existed in 1.38a and 1.51. We're using 1.51. I don't know the root of this bug, and why it was never enabled. As a result, I don't know if my fix will cause problems that I haven't seen yet. It seems innocuous enough.
reference: http://www.zen-cart.com/showthread.php?185671-zen_image_submit

Our fix was to change the function for zen_image_submit() so that CSS buttons inherit the parameters variable just like the image counterparts do.

In /includes/functions/html_output.php
Line near 268 reads:
if (strtolower(IMAGE_USE_CSS_BUTTONS) == 'yes' && strlen($alt)<30) return zenCssButton($image, $alt, 'submit', $sec_class /, $parameters = ''/ );

Remove the comments and the = '' so it reads:
if (strtolower(IMAGE_USE_CSS_BUTTONS) == 'yes' && strlen($alt)<30) return zenCssButton($image, $alt, 'submit', $sec_class , $parameters );

That's it.

Again, I don't know repercussions, but a quick run through our site seems OK. And this issue seems to be fixed, for us at least.

Does anyone use this solution? I'm having the same issue and i'm using CSS buttons, i would like to try this but i'm scared something wil backfire :-) No orders is worse then double orders ;-)