Hi all,
I experienced ongoing issues with a setup using a single payment method (only one payment method enabled): the Credit card fields are not displayed.
It was brought to my attention by a customer of mine. We had a fix already, and some were related to VM 3.6 improvements and fixes.
https://forum.virtuemart.net/index.php?topic=143564.msg507826#msg507826
Testing environments:
- Joomla 3.9.18, VirtueMart 3.6.10
- Joomla 3.9.18, VirtueMart 3.8.2
Of course, I have checked with the different settings for VirtueMart Configuration > Checkout > Enable Automatic Selected Payment:
1. The only time it works, it is when it is set to "None", and the first time only, before it is selected once.
See screenshot 1 (edit to add the screenshots)
2. Then for a second transaction within the same session, the credit card fields are not displayed. They come back once the cookies and cache are cleaned.
See screenshot 2
3. Same problem with Enable Automatic Selected Payment is SET to One payment method or to "No preference"
Single payment method tested:
- Paypal alone, set up with Paypal Payment Pro (with credit card fields)
- Authorize.net alone
For my Stripe plugin, I found a fix for VM 3.6.10, that doesn't work with 3.8.2.
It is a one line change, inside the method `plgVmOnCheckAutomaticSelectedPayment()`
function plgVmOnCheckAutomaticSelectedPayment(VirtueMartCart $cart, array $cart_prices = array(), &$paymentCounter)
{
$return = $this->onCheckAutomaticSelected($cart, $cart_prices);
if (method_exists($cart, 'getST'))
{
vmdebug('plgVmPaymentStripe -> plgVmOnCheckAutomaticSelectedPayment, method_exists($cart, \'getST\'), VM_REV some updates: ', VM_REV);
return $return; // Current code
// return 0; // FIXED with 0 @test #134 VM 3.6.10
}
else if (isset($return))
{
vmdebug('plgVmPaymentStripe -> plgVmOnCheckAutomaticSelectedPayment, VM_REV common case: ', VM_REV);
return 0;
}
else
{
return null;
}
}
I also tested with one single line, with no luck.
return $this->onCheckAutomaticSelected($cart, $cart_prices, $paymentCounter); // NOT GOOD @test #134 VM 3.6.10, VM 3.8.2
So I am sure that if we can fix it for Paypal and Authorize.net, it could fix potentially other plugins when used on their own. Also, it may be needed to catch the VM version to prevent backward compatibility issues.
Note: I read and tried some code from these posts:
http://forum.virtuemart.net/index.php?topic=143589.0
http://forum.virtuemart.net/index.php?topic=143386.15
Anyone with the same issue, please?
-- EDIT: I added 2 screenshots in my initial post, and made it clearer --
Possible workaround, try adding
$cart->automaticSelectedPayment=false;
$cart->setCartIntoSession();
to the plgVmonSelectedCalculatePricePayment function in your plugin.
public function plgVmonSelectedCalculatePricePayment(VirtueMartCart $cart, array &$cart_prices, &$cart_prices_name)
{
$cart->automaticSelectedPayment=false;
$cart->setCartIntoSession();
return $this->onSelectedCalculatePrice($cart, $cart_prices, $cart_prices_name);
}
}
Still an active bug effecting Virtuemart 3.8.0 and above
using the native Virtuemart checkout and payment/shipment plugins with additional fields.
With only one payment plugin the cart sets automaticSelectedPayment to true.
For two or more payment plugins the cart sets automaticSelectedPayment to false.
this is used by
\components\com_virtuemart\views\cart\tmpl\default_pricelist.php
which only displays extra fields when automaticSelectedPayment is set to false
and two or more payment plugins are present.
With only one plugin these fields are not shown.
The effect on plugins varies. Some will just lose some functionality, whilst others will stop working altogether.
QuotePossible workaround, try adding
$cart->automaticSelectedPayment=false;
$cart->setCartIntoSession();
to the plgVmonSelectedCalculatePricePayment function in your plugin.
Thank you ssc3 !
It looks good to me. Further tests and more investigation on when blame/history the VM code has been updated.