VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: The Yellow Fellow on August 08, 2016, 17:02:14 PM

Title: Cart not emptied after checkout
Post by: The Yellow Fellow on August 08, 2016, 17:02:14 PM
When customers place an order, their cart is not emptied after checkout. The next time they add an item to the cart, the items from the last order are still in there. How can I fix that?
Title: Re: Cart not emptied after checkout
Post by: GJC Web Design on August 08, 2016, 21:46:28 PM
First by providing information!

http://forum.virtuemart.net/index.php?topic=79799.0

http://forum.virtuemart.net/index.php?topic=104795.0

the cart is emptied by the payment plugin.. so check what ever one your using
Title: Re: Cart not emptied after checkout
Post by: The Yellow Fellow on August 09, 2016, 13:27:29 PM
Okay sorry, missed that...

I'm using VM3.0.17.4 with the 'standard' payment plugin on Joomla 3.6.2
Title: Re: Cart not emptied after checkout
Post by: GJC Web Design on August 09, 2016, 13:33:09 PM
standard payment plug hasn't changed for ages
the code is there in plugins\vmpayment\standard\standard.php to empty the cart

$modelOrder->updateStatusForOneOrder ($order['details']['BT']->virtuemart_order_id, $order, TRUE);

      //We delete the old stuff
      $cart->emptyCart ();
      vRequest::setVar ('html', $html);
      return TRUE;
   }

Works on all my installs so have no further ideas...  :(
Title: Re: Cart not emptied after checkout
Post by: The Yellow Fellow on August 09, 2016, 15:11:33 PM
I figured out that inside the function in standard.php that holds the code you just mentioned, there's an if-statement that is true so it returns FALSE:


if (!$this->selectedThisElement ($method->payment_element)) {
    return FALSE;
}


This gets fired so the code doesn't even reach the $cart->emptyCart (); part...
Title: Re: Cart not emptied after checkout
Post by: GJC Web Design on August 09, 2016, 17:08:22 PM
hmmm.. on any other payment method I check the check is

if(!$this->selectedThisElement($this->_currentMethod->payment_element)) {
         return FALSE;
      }

have informed Milbo
Title: Re: Cart not emptied after checkout
Post by: Milbo on August 09, 2016, 21:32:31 PM
if the so, he need to change it in the whole function
Title: Re: Cart not emptied after checkout
Post by: The Yellow Fellow on August 11, 2016, 08:25:15 AM
GJC's suggestion unfortunately didn't do the trick.
I commented out the part:

/*
if (!$this->selectedThisElement ($method->payment_element)) {
   return FALSE;
}
*/

from the plgVmConfirmedOrder function (just to see if it works) and now it works just fine!
Title: Re: Cart not emptied after checkout
Post by: Jörgen on August 11, 2016, 08:31:17 AM
Doesn´t this also execute the standard payment when only other payments should be triggered ?

regards

Jörgen @ Kreativ Fotografi
Title: Re: Cart not emptied after checkout
Post by: GJC Web Design on August 11, 2016, 14:06:58 PM
QuoteDoesn´t this also execute the standard payment when only other payments should be triggered ?

agree.. the check is to test if this is the payment plugin we need
Title: Re: Cart not emptied after checkout
Post by: The Yellow Fellow on August 11, 2016, 14:28:39 PM
Well it is...
How can it be this check fails (or succeeds, depending on how you look at it)?
Title: Re: Cart not emptied after checkout
Post by: Jörgen on August 11, 2016, 14:36:34 PM
If th funktion return FALSE it exits without messing with data that not belongs to this plugin :)

Otherwise it is the chosen payment method and OK to compute.

regards

Jörgen @ Kreativ Fotografi