VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: ssc3 on September 11, 2019, 16:40:04 PM

Title: VM3.6.1 10121 Revision 10115 preventing some plugins from been selected.
Post by: ssc3 on September 11, 2019, 16:40:04 PM
Revision 10115 (virtuemart): - customfields for shoppergroups

Changes to cart.php seem to be preventing some payment plugins with extra fields on the cart page from been selected.

This occurs when one payment method is published.

If you have two or more methods published the cart will work as normal

Tested with native Authorize.Net as the only payment method.


See code changes in core at

http://dev.virtuemart.net/projects/virtuemart/repository/revisions/10115/diff/trunk/virtuemart/components/com_virtuemart/helpers/cart.php



I think the cause is


       function plgVmOnCheckAutomaticSelectedPayment(VirtueMartCart $cart, array $cart_prices = array(), &$paymentCounter) {

$return = $this->onCheckAutomaticSelected($cart, $cart_prices);
if (isset($return)) {
return 0;
} else {
return NULL;
}
}


This allows the credit card fields to be visible when the payment is selected.

There are a lot of third party plugins using that code as Authorize.Net is one of the older VM plugins.

Finding a fix would help keep them working.
Title: Re: VM3.6.1 10121 Revision 10115 preventing some plugins from been selected.
Post by: StefanSTS on September 11, 2019, 17:24:46 PM
There were some changes in this one I guess.
http://dev.virtuemart.net/attachments/1179/com_virtuemart.3.6.1.10134_package_or_extract.zip
Title: Re: VM3.6.1 10121 Revision 10115 preventing some plugins from been selected.
Post by: ssc3 on September 16, 2019, 10:48:42 AM

    /**
     * plgVmOnCheckAutomaticSelectedPayment
     * Checks how many plugins are available. If only one, the user will not have the choice. Enter edit_xxx page
     * The plugin must check first if it is the correct type
     * @author Valerie Isaksen
     * @param VirtueMartCart cart: the cart object
     * @return null if no plugin was found, 0 if more then one plugin was found,  virtuemart_xxx_id if only one plugin is found
     *
     */


I think the problem is plgVmOnCheckAutomaticSelectedPayment is no longer allowed to return 0.

The original specification allowed this.

Any plugin that does this can no longer be selected.
Title: Re: VM3.6.1 10121 Revision 10115 preventing some plugins from been selected.
Post by: Milbo on September 16, 2019, 15:00:35 PM
http://dev.virtuemart.net/attachments/1183/com_virtuemart.3.6.1.10150_package_or_extract.zip

Plugins should just call

function plgVmOnCheckAutomaticSelectedPayment(VirtueMartCart $cart, array $cart_prices = array(), &$paymentCounter) {
return $this->onCheckAutomaticSelected($cart, $cart_prices, $paymentCounter);
}


which calls the rest and that works pretty generic. The pluginpart is then in "checkConditions", which be use its own code, call the parent and use its own code again.

The old checkAutomatic thing was quite shitty. It works now clean. Before, for example, we had to set the checkbox in the cart by js to enable an automatic set shipment/payment, when more than one available. Now you get a checkbox always for the first option.
Title: Re: VM3.6.1 10121 Revision 10115 preventing some plugins from been selected.
Post by: Robert_ITMan on April 22, 2020, 20:44:53 PM
Sorry - I don't understand how to get this to work now - currently testing PHP 7.3 / J 3.9.18 / VM 3.6.11 10302

Looks like this is still an issue - did something change here? Notice Configuration settings are ignored for: "Enable Automatic Selected Payment". No matter what I select it is never selected in the cart by default.

Notice the cart no longer auto selects a Payment: No payment selected - even when there is only 1 to select.

P.S. UPDATED - I removed notes about shipping. Sorry I thought I also had an issue with "Enable Automatic Selected Shipment" not selecting or seeing my shipping method - but after noticed the shipping plugin was somehow unpublished (?!) ... publishing it fixed that (again - sorry)

Title: Re: VM3.6.1 10121 Revision 10115 preventing some plugins from been selected.
Post by: Milbo on April 22, 2020, 21:09:18 PM
At least a false alert. :-)

Makes me happy :-)