Update Payment/shipment plugin using new core restrictions

Written by Max Milbers on .

The VirtueMart Core version has new restrictions for shipment and payment methods, which are provided by the core. 

  • By shoppergroup
  • category, blocking category
  • country, blocking country
  • min, max amount

and for payments additionally

  • shipment

It is relativly simple to update an existing plugin to use the provides restrictions. The system is implemented als legacy default mode system. So any unadjusted plugin works as before.

First we must update the xml file and tell VirtueMart that the plugin is updated. Just add

<field name="checkConditionsCore" value="1" default="1" type="hidden"/>

Virtuemart shows now the new core restrictions on the first tab.

We need another line in the plugin constructor to add automatically the "varsToPush" to the method.

$this->addVarsToPushCore($varsToPush, 1);

The first parameter is your $varsToPush variable, which is later used in $this->setConfigParameterable($this->_configTableFieldName, $varsToPush). The second parameter says if it is a payment or shipment.

Finally we just need to update the "checkConditions" function. For example

- The payment "default" uses any restrictions provided by the core and has no extra restrictions, it is enough to remove the whole function.
- in case of the paypal plugin, it is enough to test for the paypal extra restrictions (publishup, publishdown) and execute then the parent function.

protected function checkConditions($cart, $activeMethod, $cart_prices) {

//Check method publication start
if ($activeMethod->publishup) {
$nowDate = JFactory::getDate();
$publish_up = JFactory::getDate($activeMethod->publishup);
if ($publish_up->toUnix() > $nowDate->toUnix()) {
return FALSE;
if ($activeMethod->publishdown) {
$nowDate = JFactory::getDate();
$publish_down = JFactory::getDate($activeMethod->publishdown);
if ($publish_down->toUnix() <= $nowDate->toUnix()) {
return FALSE;

return parent::checkConditions($cart, $activeMethod, $cart_prices);


In case of the default shipment, we just could add two lines, to use the old values.

$method->min_amount = $method->orderamount_start;
$method->max_amount = $method->orderamount_stop;

The function plgVmSetOnTablePluginShipment regarding plgVmSetOnTablePluginPayment can be used to adjust old values to the new ones. In the core we removed this dirty construction, and just updated the keys by sql.

$q = 'UPDATE `#__virtuemart_shipmentmethods` SET `shipment_params`= REPLACE(`shipment_params`, "orderamount_start", "min_amount") WHERE `shipment_element` ="weight_countries"';