Author Topic: [SOLVED]Duplicate orders & payments when double-clicking Confirm Purchase button  (Read 10969 times)

Robert_ITMan

  • Jr. Member
  • **
  • Posts: 160
    • websites developed and managed @ ourfingertips.com
  • VirtueMart Version: LIVE 3.2.12 and testing latest
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.
Let me know if I can help in anyway!

Hope all is good with you and yours - stay safe! So far all is good with me and mine.

www.ourfingertips.com - websites developed and managed @ ourfingertips

Let me help you make the most of the technology at our fingertips

K&K media production

  • VirtueMart Developer Team
  • Global Moderator
  • Full Member
  • *
  • Posts: 838
  • VirtueMart Version: VM3 on J3
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

Robert_ITMan

  • Jr. Member
  • **
  • Posts: 160
    • websites developed and managed @ ourfingertips.com
  • VirtueMart Version: LIVE 3.2.12 and testing latest
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?
Let me know if I can help in anyway!

Hope all is good with you and yours - stay safe! So far all is good with me and mine.

www.ourfingertips.com - websites developed and managed @ ourfingertips

Let me help you make the most of the technology at our fingertips

K&K media production

  • VirtueMart Developer Team
  • Global Moderator
  • Full Member
  • *
  • Posts: 838
  • VirtueMart Version: VM3 on J3
Do you have no mirror site for testing?

I can't say more about this problem.

Robert_ITMan

  • Jr. Member
  • **
  • Posts: 160
    • websites developed and managed @ ourfingertips.com
  • VirtueMart Version: LIVE 3.2.12 and testing latest
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!
Let me know if I can help in anyway!

Hope all is good with you and yours - stay safe! So far all is good with me and mine.

www.ourfingertips.com - websites developed and managed @ ourfingertips

Let me help you make the most of the technology at our fingertips

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10092
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
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.

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?
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Robert_ITMan

  • Jr. Member
  • **
  • Posts: 160
    • websites developed and managed @ ourfingertips.com
  • VirtueMart Version: LIVE 3.2.12 and testing latest
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.
Let me know if I can help in anyway!

Hope all is good with you and yours - stay safe! So far all is good with me and mine.

www.ourfingertips.com - websites developed and managed @ ourfingertips

Let me help you make the most of the technology at our fingertips

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3399
  • VirtueMart Version: 3.8.9
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.
Regards
A

Joomla 3.9.25
php 7.4

Robert_ITMan

  • Jr. Member
  • **
  • Posts: 160
    • websites developed and managed @ ourfingertips.com
  • VirtueMart Version: LIVE 3.2.12 and testing latest
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 )
Let me know if I can help in anyway!

Hope all is good with you and yours - stay safe! So far all is good with me and mine.

www.ourfingertips.com - websites developed and managed @ ourfingertips

Let me help you make the most of the technology at our fingertips

Robert_ITMan

  • Jr. Member
  • **
  • Posts: 160
    • websites developed and managed @ ourfingertips.com
  • VirtueMart Version: LIVE 3.2.12 and testing latest
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]
Let me know if I can help in anyway!

Hope all is good with you and yours - stay safe! So far all is good with me and mine.

www.ourfingertips.com - websites developed and managed @ ourfingertips

Let me help you make the most of the technology at our fingertips

Robert_ITMan

  • Jr. Member
  • **
  • Posts: 160
    • websites developed and managed @ ourfingertips.com
  • VirtueMart Version: LIVE 3.2.12 and testing latest
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:
Code: [Select]
<?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:
Code: [Select]
//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:
Code: [Select]
<?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
Code: [Select]
<?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]
Let me know if I can help in anyway!

Hope all is good with you and yours - stay safe! So far all is good with me and mine.

www.ourfingertips.com - websites developed and managed @ ourfingertips

Let me help you make the most of the technology at our fingertips

fale

  • Beginner
  • *
  • Posts: 34
This will be done in the new version?

Robert_ITMan

  • Jr. Member
  • **
  • Posts: 160
    • websites developed and managed @ ourfingertips.com
  • VirtueMart Version: LIVE 3.2.12 and testing latest
fale - good question, I sure hope so.
Let me know if I can help in anyway!

Hope all is good with you and yours - stay safe! So far all is good with me and mine.

www.ourfingertips.com - websites developed and managed @ ourfingertips

Let me help you make the most of the technology at our fingertips

Robert_ITMan

  • Jr. Member
  • **
  • Posts: 160
    • websites developed and managed @ ourfingertips.com
  • VirtueMart Version: LIVE 3.2.12 and testing latest
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
Let me know if I can help in anyway!

Hope all is good with you and yours - stay safe! So far all is good with me and mine.

www.ourfingertips.com - websites developed and managed @ ourfingertips

Let me help you make the most of the technology at our fingertips

hotrod

  • Jr. Member
  • **
  • Posts: 132
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..

VirtueMart 3.8.4
Joomla! 3.9.21