Author Topic: Duplicate Orders when Checking Out with PayPal - VM 2.6.4  (Read 9449 times)

alex2311

  • Beginner
  • *
  • Posts: 10
Duplicate Orders when Checking Out with PayPal - VM 2.6.4
« on: May 25, 2014, 07:59:57 am »
Hello,

When checking out using "VM Payment - Standard", only one order is generated in the backend.  When checking out with "VM Payments - PayPal", the order is duplicated in the back end with a different Order Number.  PayPal transacts correctly and the original order status is updated indicating payment was made for the first order.  The second order does nothing.

I checked the code as suggested in the message http://forum.virtuemart.net/index.php?topic=123644.msg422091#msg422091 but it has already been included.

Any guidance in addressing this issue will be greatly appreciated.

Cheers,

Alex

alex2311

  • Beginner
  • *
  • Posts: 10
Re: Duplicate Orders when Checking Out with PayPal - VM 2.6.4
« Reply #1 on: May 29, 2014, 14:51:30 pm »
We cannot be the only people experiencing this?  We have been able to replicate on two sites so far?  Any one else experiencing this?

Any help/guidance will be greatly appreciated.

Alex

alex2311

  • Beginner
  • *
  • Posts: 10
Re: Duplicate Orders when Checking Out with PayPal - VM 2.6.4
« Reply #2 on: May 30, 2014, 17:13:14 pm »
Just went to VM 2.6.6....  And still getting duplicates.

I uninstalled the modules and dropped all the VM table from the database.  I then did a complete re-install...  No errors on install...  But still getting duplicates when checking out with PayPal.

Any advice would be greatly appreciated...

Alex

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9972
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Duplicate Orders when Checking Out with PayPal - VM 2.6.4
« Reply #3 on: June 03, 2014, 15:06:27 pm »
Please check the override of your cart layout. We replaced the link against a button, with a js, which prevents that you can hit the button twice. We also changed the checkout. Do you use some OPC of a 3rd party?
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

alex2311

  • Beginner
  • *
  • Posts: 10
Re: Duplicate Orders when Checking Out with PayPal - VM 2.6.4
« Reply #4 on: June 04, 2014, 13:15:35 pm »
Hi Milbo,

Thanks for your reply.  The site has "No Override" selected for the Cart Layout.  I am using no other 3rd party One Page Check (OPC) functionality for Virtuemart.  I am only using the default that comes with the Virtuemart download package.

I will PM you a login so you can have a poke around...

Thanks for your help/

Alex

multigeo

  • Beginner
  • *
  • Posts: 4
Re: Duplicate Orders when Checking Out with PayPal - VM 2.6.4
« Reply #5 on: June 05, 2014, 14:44:29 pm »
I have been battling this exact same issue.
My site is on J2.5.20 / VM2.6.6 / VM native OPC
I am using overrides, but the same issue existed when removing all of them, so that's not where the problem lies.
Neither makes switching OPC on/off any difference.

I went through the override for the checkout page and noticed the following:

illustrating the procedure:
  • cart is filled
  • call cart view from menu
  • $this->checkout_task = 'checkout' + checkout button at bottom does not show 'Confirm'
  • user is not logged in, so do login
  • Press checkout button to proceed to next step
  •   $this->checkout_task = 'confirm' + checkout button at bottom does show 'Confirm'
  • Order is confirmed on screen
  • 2 sets of order mails (to buyer + to shop) are mailed
  • backend shows the 2 new orders, both identical, exept for order_number + order_id

After lots of experimenting and playing around I solved it (more extensive testing needed at this time) as follows:
It seems that each click on the checkout button generates an order.
So I disabled it in the override unless $this->checkout_task = 'confirm'
At the same time I clear the variable $taskRoute.

I'm sure this is not the correct solution, but I hope it gets me by until a proper fix is known.
I attached my override for you as an example. (remove the TXT extension)
Examine it well before playing with it. It stores in folder: \templates\<template>\html\com_virtuemart\cart

Any comments from VM guru's is very welcome

Cheers
André

[attachment cleanup by admin]

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9972
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Duplicate Orders when Checking Out with PayPal - VM 2.6.4
« Reply #6 on: June 05, 2014, 19:17:37 pm »
Thanks for your reply.  The site has "No Override" selected for the Cart Layout.  I am using no other 3rd party One Page Check (OPC) functionality for Virtuemart.  I am only using the default that comes with the Virtuemart download package.

I will PM you a login so you can have a poke around...

We talk about overrides done automatically by joomla and your template. You sent me a pm, but I need superuser rights. Honoring our work of course increases our motivation http://extensions.virtuemart.net/support/virtuemart-supporter-membership-detail


After lots of experimenting and playing around I solved it (more extensive testing needed at this time) as follows:
It seems that each click on the checkout button generates an order.
So I disabled it in the override unless $this->checkout_task = 'confirm'
At the same time I clear the variable $taskRoute.

I'm sure this is not the correct solution, but I hope it gets me by until a proper fix is known.
I attached my override for you as an example. (remove the TXT extension)
Examine it well before playing with it. It stores in folder: \templates\<template>\html\com_virtuemart\cart

Any comments from VM guru's is very welcome

Cheers
André

Hmm, actually it should create a pending order, but update the old one if there is already one. I just also noticed myself, cancelling the paypal process leads to a new order and the old is in pending state. Thank you for this exact observation.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

hotrod

  • Jr. Member
  • **
  • Posts: 104
  • Silver Supporting Member
Re: Duplicate Orders when Checking Out with PayPal - VM 2.6.4
« Reply #7 on: June 11, 2014, 19:08:32 pm »
I'm in Another thread.. here..  http://forum.virtuemart.net/index.php?topic=123644.msg424933#msg424933
Getting duplicate orders and payment all of a sudden..  did nothing..  turning off SSL stopped it..  any Clue what it can be?
updated last week and got many orders with no problems.. then 3:pm yesterday it went to hell..

VM 2.6.6 
VirtueMart 2.6.8 (Patched 9/18)
Joomla 2.5.22
PHP Version    5.4.32 
Dedicated Server.
Proud Virtuemart Supporter http://forum.virtuemart.net/index.php?topic=124355.0

stensbo

  • Jr. Member
  • **
  • Posts: 87
Re: Duplicate Orders when Checking Out with PayPal - VM 2.6.4
« Reply #8 on: June 11, 2014, 20:12:52 pm »
Using Joomla 2.5.20, Multi language (only DK in VM), Beez20 copy template, Virtuemart 2.6.6, PHP Version 5.3.27, vm override.

Joomla site is live - danrider.dk -  but vm shop is only for registered shopper.


When checking out using "VM Payment - Standard", only one order is generated in the backend.

Use vmpayment plugin Standard  -  I have had orders with no issue after upgrade to 2.6.6 - but yesterday I got double ordres with different order no.

alex2311

  • Beginner
  • *
  • Posts: 10
Re: Duplicate Orders when Checking Out with PayPal - VM 2.6.4
« Reply #9 on: June 22, 2014, 17:57:27 pm »
Thanks everyone for your comments....  I have tried what people have suggested but unfortunately it did not work for.  I have tried to figure out why the function is getting called more than once to generate multiple Orders.  But with my limited PHP coding experience (OK...really no experience.. I have been playing in it for a month.. ;) ), I have had no success (no real surprise there....). But what I did come up with is a work-around that works for me..  It may not be elegant, but it works....!

What follows are the changes I made to make it work... REMEMBER I AM NOT A CODER!!!!!!  So please ensure that you review the changes and make sure it is applicable to you!

The following changes have been made to the "components\com_virtuemart\helpers\cart.php" file:
  • MAKE A BACKUP OF THE CART.PHP FILE!!!!!!!
  • In the cart.php file locate the function "public function add($virtuemart_product_ids=null,&$errorMsg='') "
  • After the line "$post = JRequest::get('default');" add the following line....    "$_SESSION['CartBeenProcessed']=0;"   This will set the 'CartBeenProcessed' to 0 every time an item is added to the cart.
  • Find the function "function confirmedOrder() {".  This is the function creates the orders..
  • Modify the code to include the "$_SESSION['CartBeenProcessed']" as seen below:

                    //Just to prevent direct call:
          if ($this->_dataValidated && $this->_confirmDone && $_SESSION['CartBeenProcessed']==0) {
             $_SESSION['CartBeenProcessed']=1;
             $orderModel = VmModel::getModel('orders');

    The If statement will now check in addition to see if the Cart has been put through this process before.  If it hasn't (is set to "0") the code will run.  The first thing it will do is change the flag "1" so it knows that it has been action so it won't be able to confirm the order more than one.

This code works for me..... it might work for you?  Hopefully the next version will able to fix the root cause of the problem......

Cheers,

Alex

hotrod

  • Jr. Member
  • **
  • Posts: 104
  • Silver Supporting Member
Re: Duplicate Orders when Checking Out with PayPal - VM 2.6.4
« Reply #10 on: June 22, 2014, 19:05:13 pm »
Wow.. Nice.. I may have to try this..
VirtueMart 2.6.8 (Patched 9/18)
Joomla 2.5.22
PHP Version    5.4.32 
Dedicated Server.
Proud Virtuemart Supporter http://forum.virtuemart.net/index.php?topic=124355.0

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9972
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Duplicate Orders when Checking Out with PayPal - VM 2.6.4
« Reply #11 on: June 23, 2014, 15:34:54 pm »
Then it should be also enough to write

if ($this->_dataValidated && $this->_confirmDone and !$this->_inCheckOut) {

because we have such a variable _inCheckOut
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

alex2311

  • Beginner
  • *
  • Posts: 10
Re: Duplicate Orders when Checking Out with PayPal - VM 2.6.4
« Reply #12 on: June 23, 2014, 19:03:01 pm »
Thanks Milbo,

Being that I am a novice at this... I can't see where the $this->_inCheckOut is set to true after it processed so that it can't be triggered again?

Anyway... I took my code out and tried "if ($this->_dataValidated && $this->_confirmDone and !$this->_inCheckOut) {" as suggested by Milbo.... Unfortunately my duplicates came straight back.  I even tried setting    $this->_inCheckOut=true; straight after... Duplicates still occurred.  Something is obviously resetting the flag somewhere....

So I have put my code back and the duplicates have stopped.

Alex

hotrod

  • Jr. Member
  • **
  • Posts: 104
  • Silver Supporting Member
Re: Duplicate Orders when Checking Out with PayPal - VM 2.6.4
« Reply #13 on: June 23, 2014, 19:33:11 pm »
Watching this closely..  this should work for my Authorize.net I would assume..

Do you know if your double order are just from Internet Explorer?  Mine are..
VirtueMart 2.6.8 (Patched 9/18)
Joomla 2.5.22
PHP Version    5.4.32 
Dedicated Server.
Proud Virtuemart Supporter http://forum.virtuemart.net/index.php?topic=124355.0

alex2311

  • Beginner
  • *
  • Posts: 10
Re: Duplicate Orders when Checking Out with PayPal - VM 2.6.4
« Reply #14 on: June 24, 2014, 03:26:19 am »
Hi Hotrod,

In my instance it did not matter if it was IE or Chrome.  I was consistently getting duplicates on PayPal Payments only.

Cheers,

Alex