VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: Robert_ITMan on March 19, 2014, 18:02:04 PM

Title: [SOLVED]Duplicate orders & payments when double-clicking Confirm Purchase button
Post by: Robert_ITMan on March 19, 2014, 18:02:04 PM
PROBLEM: Duplicate orders and payments when double-clicking Confirm Purchase button

Please Help! VirtueMart 2 (VM2) needs a better action when clicking the Confirm Purchase button! On click it needs to instantly show 'processing...' to both (1) eliminate duplicate orders and payments with double-clicking, and (2) assure customers it is processing.

Any and all ideas welcome - if I solve this myself I will publish my solution here.
Title: Re: Duplicate orders and payments when double-clicking Confirm Purchase button
Post by: K&K media production on March 19, 2014, 23:44:29 PM
As far as i know this is solved in next vm version. Please try the test version 2.5.4 from http://dev.virtuemart.net/projects/virtuemart/files
Title: Re: Duplicate orders and payments when double-clicking Confirm Purchase button
Post by: Robert_ITMan on March 20, 2014, 00:06:43 AM
Thanks for the reply kkmediaproduction - our site is live and using current stable version 2.0.26d and I need a solution for this right away. It looks like ver 2.5.4 is not ready and I'm guessing it will be too time consuming / painful / expensive to try upgrading at this time.

Please help! Any suggestions or solutions?
Title: Re: Duplicate orders and payments when double-clicking Confirm Purchase button
Post by: K&K media production on March 20, 2014, 00:23:54 AM
Do you have no mirror site for testing?

I can't say more about this problem.
Title: Re: Duplicate orders and payments when double-clicking Confirm Purchase button
Post by: Robert_ITMan on March 20, 2014, 00:28:05 AM
Thanks again for the reply kkmediaproduction - yes I have a test site but no solutions myself yet... hoping someone in the community has already solved this... seems like a big oversight to me!
Title: Re: Duplicate orders and payments when double-clicking Confirm Purchase button
Post by: Milbo on March 20, 2014, 09:17:09 AM
Quote from: Robert_ITMan on March 20, 2014, 00:06:43 AM
Thanks for the reply kkmediaproduction - our site is live and using current stable version 2.0.26d and I need a solution for this right away.

The solution would automatically make a new version. Right? You would be the first testing it, right? Oh damn, I really would go with vm2.5.4, which is almost the same thing, just tested already by around 100 people.

Quote from: Robert_ITMan on March 20, 2014, 00:06:43 AM
It looks like ver 2.5.4 is not ready and I'm guessing it will be too time consuming / painful / expensive to try upgrading at this time.

Actually it is very likely just a 5 minutes action. Why do you think it takes longer? Did you hack the core?
Title: Re: Duplicate orders and payments when double-clicking Confirm Purchase button
Post by: Robert_ITMan on March 20, 2014, 14:41:34 PM
Thanks Milbo for your replies! If I understand you correctly you are saying that upgrading to 2.5.4 will take 5 minutes and will work so long as I did not hack the core... so I should be good then and I'll have to try it for the good of the community. I will let you know how I make out and how long it took to upgrade and test to make sure it works will my plugins and related components.
Title: Re: Duplicate orders and payments when double-clicking Confirm Purchase button
Post by: AH on March 20, 2014, 14:51:44 PM
Please only do this in test at first!

It should be fine BUT their are changes to the configuration etc that you may wish to review prior to updating in live.
Title: Re: Duplicate orders and payments when double-clicking Confirm Purchase button
Post by: Robert_ITMan on March 20, 2014, 19:15:30 PM
Thanks Hutson for your advise - I will certainly be using a test site to see if it works OK first.

:-\ I will have to come back to this another time because the dev site isn't loading for me this morning !!? ( http://dev.virtuemart.net/projects/virtuemart/files )
Title: Re: Duplicate orders and payments when double-clicking Confirm Purchase button
Post by: Robert_ITMan on March 20, 2014, 20:13:55 PM
I couldn't wait so I think I found a working solution for VM 2.0.26d as everything worked as expected for me when I tested double-clicking the Confirm Purchase buttton ... no duplicate orders or payments were created (yeah!). I will test further to make sure before marking this as solved.

Edited file: /templates/(my-template)/html/com_virtuemart/cart/default.php
[code removed - it didn't work - found a better solution 2014-04-18 and posted it below]
Title: Re: Duplicate orders and payments when double-clicking Confirm Purchase button
Post by: Robert_ITMan on April 18, 2014, 22:39:45 PM
I think I eliminated the  issue with receiving duplicate orders on double-click. Now when clicking the button it shows "Please wait ..." and hides the button so there is no way anyone could click it twice. The code is below for both template files affecting when checking out / confirming an order (cart/default.php) and for registering / updating an account (user/edit.php).

IGNORE previous code and suggestions as it didn't work - we still received duplicate orders from double-clicking.

ALSO this issue is not resolved when updating to VM 2.5.4 or 2.6 as suggested - and yes I updated the template files (actually these updates caused a new issue with accepting terms of service not working) The following code is for 2.026d but I have also updated it to work for 2.6.0 and it works there too (along with a work around for having terms of service without the check box).

Edited file: /templates/(my-template)/html/com_virtuemart/cart/default.php
Replace <form ... with:

<?php /* script to disable double clicking and show progress 
plus add onsubmit="return onSubmitButton()" to the form and styles around the buttons below */ 
?>

<script type="text/javascript">
function onSubmitButton(){
        document.getElementById("submitButtonDiv").style.display = "none";

if (navigator.appName == "Microsoft Internet Explorer") {
document.getElementById("progressBar").innerHTML = "";
document.getElementById("progressBar").style.display = "block";
document.getElementById("progressBar").innerHTML = "<img src='/images/progress.gif' alt='please wait'>";
} else {
document.getElementById("progressBar").style.display = "block";
}
}
</script>
<form method="post" id="checkoutForm" name="checkoutForm" action="<?php echo JRoute::_'index.php?option=com_virtuemart&view=cart'.$taskRoute,$this->useXHTML,$this->useSSL ); ?>" onsubmit="return onSubmitButton()">


and near the bottom replace echo $this->checkout_link_html; with:

//echo $this->checkout_link_html; // replaced with following button allowing only single click
?>
<?php // begin button allowing only single click ?>
<?php /* includes above script to disable double clicking and show progress */ ?>
    <div style="margin:10px 0 0 0;">
    <div id="submitButtonDiv">
<?php /* hide    <a id="btnCheckoutSubmit" class="vm-button-correct" href="javascript:document.checkoutForm.submit();" name="checkout"><span>
end hide */ 
?>

<button style="margin:0;" class="button" type="submit" onclick="javascript:document.checkoutForm.submit();" >
    <?php if($this->checkout_task === 'confirm'):?>
        <?php echo JText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU');?>
    <?php else:?>
        <?php echo JText::_('COM_VIRTUEMART_CHECKOUT_TITLE');?>
    <?php endif;?>
    </button></a>
    </div>
    <div id="progressBar" style="display:none;font-family: Verdana,Geneva,Arial,Helvetica,sans-serif;
    font-size: 12px; font-weight: bold;">
    Please wait ... <img src="/images/progress.gif" height="20px" alt="Please wait">
    </div>
    </div>
<?php // end button allowing only single click ?>


Also similar solution in file: /templates/(my-template)/html/com_virtuemart/user/edit.php
Replace <form ... with:

<?php /* script to disable double clicking and show progress  
plus add onsubmit="return onSubmitButton()" to the form and styles around the buttons below */ 
?>

<script type="text/javascript">
function onSubmitButton(){
        document.getElementById("submitButtonDiv").style.display = "none";

if (navigator.appName == "Microsoft Internet Explorer") {
document.getElementById("progressBar").innerHTML = "";
document.getElementById("progressBar").style.display = "block";
document.getElementById("progressBar").innerHTML = "<img src='/images/progress.gif' alt='please wait'>";
} else {
document.getElementById("progressBar").style.display = "block";
}
}
</script>
<form method="post" id="checkoutForm" name="checkoutForm" action="<?php echo JRoute::_'index.php?option=com_virtuemart&view=cart'.$taskRoute,$this->useXHTML,$this->useSSL ); ?>" onsubmit="return onSubmitButton()">


and update your buttons (I moved mine to the bottom of the form and I also removed them from above and in the file user/edit_shopper.php

<?php /* copy begins adding buttons to bottom of form */ ?>
<?php /* includes above script to disable double clicking and show progress */ ?>
    <div class="buttonBar-right">
    <div style="float:left; text-align:right; width:608px;">
<div id="submitButtonDiv">
    <button style="margin:0;" class="button" type="submit" onclick="javascript:return myValidator(userForm, 'saveUser');" ><?php echo $this->button_lbl ?></button>
    </div>
    <div id="progressBar" style="display:none;font-family: Verdana,Geneva,Arial,Helvetica,sans-serif;
    font-size: 12px; font-weight: bold;">
    Please wait ... <img src="/images/progress.gif" height="20px" alt="Please wait">
    </div>
    </div>
    <div style="float:right;width:70px;">
    <button style="margin:0;" class="button" type="reset" onclick="window.location.href='<?php echo JRoute::_('index.php?option=com_virtuemart&view=user'); ?>'" ><?php echo JText::_('COM_VIRTUEMART_CANCEL'); ?></button>
    </div>
    </div>
<?php /* copy ends adding buttons to bottom of form */ ?>


You will want to add JText so it works for your language files and change the styles and maybe find your own progress.gif (attached here) to work with your site... but it all works for me... hope it helps you... and maybe the development team will implement something similar in the future.

[attachment cleanup by admin]
Title: Re: [SOLVED]Duplicate orders & payments when double-clicking Confirm Purchase button
Post by: fale on April 24, 2014, 22:05:28 PM
This will be done in the new version?
Title: Re: [SOLVED]Duplicate orders & payments when double-clicking Confirm Purchase button
Post by: Robert_ITMan on April 24, 2014, 23:01:01 PM
fale - good question, I sure hope so.
Title: Re: Duplicate orders & payments when double-clicking Confirm Purchase button
Post by: Robert_ITMan on May 02, 2014, 13:44:21 PM
NOT solved! We have received duplicate orders and payments at exactly the same time - and with the above in place I know it is not from double clicking! Please help me figure out where to look to solve this. Could it be our payment method, could it be a bug with VirtueMart cart?

As I'm sure I eliminated the possibility of this issue being caused by double-clicking I have created a new thread 'Duplicate orders & payments' here: http://forum.virtuemart.net/index.php?topic=123644.0
Title: Re: [SOLVED]Duplicate orders & payments when double-clicking Confirm Purchase button
Post by: hotrod on June 11, 2014, 21:27:38 PM
As of Now.. I think I fixed it..  Just turned SSL back on and my order came perfect.. 1 time..

I was doing some Google searching and found a topic on a OPC site about double orders.. and I seen something about " No Price Items" ( Can't find where I was)
That brought me back to a product my partner put up yesterday that I was reviewing and he had the price override checked and there was no final price.. and when you looked at it on the site is was -29$..  I though nothing of it untill I asked him  what did you do there.  he said nothing.. So I started trying to get the prices to work right and was having some issues getting it the way it needed to be.  Got the cost  base and final and no override to take..  turned on SSL placed an order and it was fine..    Watching an in Google real time as I type...   Lets see...  Came in Twice.. then one behind it came in once.

UGH..

Title: Re: [SOLVED]Duplicate orders & payments when double-clicking Confirm Purchase button
Post by: hotrod on June 11, 2014, 21:29:27 PM
As of Now.. I have fixed it..  Just turned SSL back on and my order came perfect.. 1 time..

I was doing some Google searching and found a topic on a OPC site about double orders.. and I seen something about " No Price Items" ( Can't find where I was)
That brought me back to a product my partner put up yesterday that I was reviewing and he had the price override checked and there was no final price.. and when you looked at it on the site is was -29$..  I though nothing of it untill I asked him  what did you do there.  he said nothing.. So I started trying to get the prices to work right and was having some issues getting it the way it needed to be.  Got the cost  base and final and no override to take..  turned on SSL placed an order and it was fine..    Watching an order in Google real time as I type...   Lets see...  Came in Twice.. then one behind it came in once.

UGH..
Title: Re: [SOLVED]Duplicate orders & payments when double-clicking Confirm Purchase button
Post by: hotrod on June 18, 2014, 17:59:31 PM
Not Fixed.. Please follow this thread..  http://forum.virtuemart.net/index.php?topic=123644.30
Title: Re: [SOLVED]Duplicate orders & payments when double-clicking Confirm Purchase button
Post by: Robert_ITMan on June 18, 2014, 19:20:55 PM
hotrod- please don't post here again unless you have added the code I provided in this thread to eliminate the possibility of double clicking.

[SOLVED] still working! The code I provided earlier continues to work for my sites in VM 2.6.6