[SOLVED]Duplicate orders & payments when double-clicking Confirm Purchase button

Started by Robert_ITMan, March 19, 2014, 18:02:04 PM

Previous topic - Next topic

Robert_ITMan

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.
WEBSITES @ OURFINGERTIPS
manage > develop > market > repeat

Save a lot of time and money when focused on building a website that works with marketing efforts to get more leads and sales from visitors.

www.ourfingertips.com

K&K media production


Robert_ITMan

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?
WEBSITES @ OURFINGERTIPS
manage > develop > market > repeat

Save a lot of time and money when focused on building a website that works with marketing efforts to get more leads and sales from visitors.

www.ourfingertips.com

K&K media production

Do you have no mirror site for testing?

I can't say more about this problem.

Robert_ITMan

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!
WEBSITES @ OURFINGERTIPS
manage > develop > market > repeat

Save a lot of time and money when focused on building a website that works with marketing efforts to get more leads and sales from visitors.

www.ourfingertips.com

Milbo

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

Robert_ITMan

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.
WEBSITES @ OURFINGERTIPS
manage > develop > market > repeat

Save a lot of time and money when focused on building a website that works with marketing efforts to get more leads and sales from visitors.

www.ourfingertips.com

AH

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 4.4.5
php 8.1

Robert_ITMan

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 )
WEBSITES @ OURFINGERTIPS
manage > develop > market > repeat

Save a lot of time and money when focused on building a website that works with marketing efforts to get more leads and sales from visitors.

www.ourfingertips.com

Robert_ITMan

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]
WEBSITES @ OURFINGERTIPS
manage > develop > market > repeat

Save a lot of time and money when focused on building a website that works with marketing efforts to get more leads and sales from visitors.

www.ourfingertips.com

Robert_ITMan

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]
WEBSITES @ OURFINGERTIPS
manage > develop > market > repeat

Save a lot of time and money when focused on building a website that works with marketing efforts to get more leads and sales from visitors.

www.ourfingertips.com


Robert_ITMan

WEBSITES @ OURFINGERTIPS
manage > develop > market > repeat

Save a lot of time and money when focused on building a website that works with marketing efforts to get more leads and sales from visitors.

www.ourfingertips.com

Robert_ITMan

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
WEBSITES @ OURFINGERTIPS
manage > develop > market > repeat

Save a lot of time and money when focused on building a website that works with marketing efforts to get more leads and sales from visitors.

www.ourfingertips.com

hotrod

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

Bronze Member
VirtueMart 4.2.4 10922
Joomla!  ‎4.3.4
PHP 8.0