Login
Register

VirtueMart

WooCommerce

Others

Docs

Support

Blog

About

Extensions for Shipping by Rules

IMPORTANT ANNOUNCEMENT: Plugin development ceased, all plugins made available freely (GPL)

With great sadness we have to announce that we are ceasing development of all our VirtueMart, WooCommerce and Joomla plugins. Effective immediately, all our plugins -- even those that were paid downloads -- are made available for free from our homepage (GPL license still applies), but we cannot and will not provide any support anymore.

It has been a great pleasure to be part of the thriving development communities of VirtueMart as well as WooCommerce. However, during the last year it became painstakingly clear that in addition to a full-time job, a young family and several other time-consuming hobbies at professional level (like being a professional singer) the plugin development and the support that it requires is not sustainable and is taking its toll. It has been an honor, but it is now time to say good bye!

Extensions for the Shipping by Rules Plugins for VirtueMart

Extensions for the Shipping by Rules plugins for VirtueMart. These plugins provide custom variables or custom functions to be used in the rules. At least version 5.0 of the Shipping by Rules plugins is required.
plg_vmshipping_rules_shipping_plugins_icon.pngplg_vmshipping_rules_shipping_plugins_icon.png
  • 25
  • 30
  • plugin
  • specific
  • vm2.0
  • vm3.0
Product Product Price
Regular Expressions for the Shipping by Rules Plugins for VirtueMart
Price : FREE
Template for Extensions for the Shipping by Rules Plugins for VirtueMart
Price : FREE
AwoCoupon Discounts for the Shipping by Rules Plugins for VirtueMart
Price : FREE
AwoCoupon discounts for Shipping by Rules for VM, Version 1.2 AwoCoupon discounts for Shipping by Rules for VM, Version 1.2
Filename: plg_opentools_vmshipmentrules_awocoupon_v1.2.zip
MIME-Type: application/zip
File size: 4936 Bytes

VirtueMart Discounts for the Shipping by Rules Plugins for VirtueMart
Price : FREE

All these plugins are "normal" Joomla plugins of plugin type "vmshipmentrules" and need to be installed via the Joomla extension manager. Upon installation they should be automatically published by the installer and their functionality should be available in the Shipping by Rules plugins (both the basic and the advanced plugin) immediately.

 

Please note that the plugin feature was added only in version 5.0 of the Shipping by Rules plugins, so you need to have at least that version installed.

 

RegExp Plugin

This plugin provides the following RegExp-related functions to the shipping by rules plugin:

RegExpMatch(pattern, value)
returns whether the value matches the expression (true/false)
RegExpMatches(pattern, value)
returns an array of all matches of regexp within the value (array)
RegExpReplace(pattern, value)
preforms a regexp replacement on the value, returns the resulting string (string)
RegExpSplit(pattern, value)
splits value using the regexp as delimiter, returns array of all substrings (excluding the delimiter) (array)
RegExpFilter(pattern, array)
returns all members of the array that match the regexp (array)

VM Coupon Prices Plugin

This plugin extends the shipping by rules plugin with two variables (couponValue and AmountAfterCoupon / salesPriceAfterCoupon) that take into account coupon discounts by the stock VirtueMart coupon system. For technical resons, these variables are not part of the Shipping by Rules plugin by default to prevent possible interferences.

By default, VirtueMart evaluates shipping costs first and coupons afterwards, so when shipping is calculated, the coupon discount is not yet calculated in general. To work around this issue, this small plugin adds to trickery to manually calculate the coupon during shipping cost evaluation. As this might interfere with VM (we have not yet run into issues, but who knows...), this functionality is not included by default, but only with this small extension plugin.

The plugin makes some more variables available:

AmountAfterCoupon / SalesPriceAfterCoupon
The total amount of the order after coupon discounts have been applied
CouponValue
The total coupon discount

 

AwoCoupon Plugin

This plugin provides access to the coupon granted by AwoCoupon. For technical reasons that coupon is not part of the Amount variable in the rules. The reason is that VirtuMart handles coupon plugins like AwoCoupon after shipping plugins, so when the shipping rules are evaluated, the coupon plugins have not been evaluated. This plugin uses the internals of the AwoCoupon component to extract the coupon discount directly and makes it available as the awodiscount variable. 

The plugin also makes some more variables available:

AwoDiscount
The total amount of the coupon discount (product discount and shipping discount) including taxes
AwoProductDiscount
The total AwoCoupon product discount including taxes
AwoProductDiscountNoTax
The total AwoCoupon product discount excluding taxes
AwoShippingDiscount
The total AwoCoupon shipping discount including taxes
AwoShippingDiscountNoTax
The total AwoCoupon shipping discount excluding taxes
AmountAfterCoupon
AmountWithTaxAfterCoupon
The order subtotal (product prices total) including taxes after AwoCoupon discounts are applied
TaxAmountAfterCoupon
The order tax amount after AwoCoupon discounts are applied
AmountWithoutTaxAfterCoupon
The order subtotal (product prices total) excluding taxes after AwoCoupon discounts are applied

 

CAVEAT: Due to the way VirtueMart processes third-party coupons, when a coupon is added or changed, the first page load does NOT have the AwoCoupon values available, because VirtueMart handles shipping methods before Coupons are evaluated. So, immediately after adding a coupon, the coupon will not be available. Only after another page reload will these values be available.

 

Template for vmshipmentrules Plugins

This is a template for developers who want to write their own plugins to extend the Shipping by Rules plugins. It can be installed, but does not provide any useful functionality, unless a programmer implements the corresponding functions.

Sometimes, shipping costs have to depend on properties (e.g. custom field values, awocoupon discounts, etc.) that are not by default provided by this plugin. Starting with version 5.0, the Shipping by Rules plugins can be extended with plugins of type "vmshipmentrules". Such extensions can add new variables, modify existing variables and add new functions (advanced version only). 

The template available for download has the complete file and code structure, which you can use as a starting point for such a plugin. You will need to adjust the file names, the .xml file and the class names. 

 

There are two triggers in the plugin class that can be reimplemented to provide/modify variables and add new functions:

function onVmShippingRulesGetCartValues(&$cartvals, $cart, $products, $method, $cart_prices)

This trigger is called right before the rules are first evaluated (and during evaluation when a scoping function like evaluate_for_categories is used). 

Function arguments
$cartvals Associative array of all defined cart variables available in the rules. This array can be modified by adding new variables or changing existing entries. The variable name is used as the key, its value is the array value of the entry in the associative array.
$cart The VirtueMartCart object of the whole order. This includes all products in the order, information about the shopper, the address, the shipment and payment methods (although payment plugins have not neccessarily been processed).
$products The list of products for which the cart variables are supposed to be calculated. Always use this list of products rather than $cart->products, because this trigger can also be called for a subset of the cart (e.g. to calculate values for all articles in only one category when evaluate_for_categories is evaluated)
$method The configuration of the shipment method.
$cart_prices The cart prices of the whole cart. If this trigger is called for only a subset of the cart, this argument is null.
Return value: None / Ignored

Example:

function onVmShippingRulesGetCartValues(&$cartvals, $cart, $products, $method, $cart_prices) {
    $cartvals['coupon'] = $cart->couponCode;
}

function onVmShippingRulesRegisterCustomFunctions()

This trigger is called when the Shipping by Rules plugin is initialized. It is used to register custom function callbacks.

This trigger is called right before the rules are first evaluated (and during evaluation when a scoping function like evaluate_for_categories is used). 

Function arguments
-         none
Return value:
 

Associative array containing function definitions. The array keys are the function names to be used in the rules, the corresponding array values are the callback functions (either a string to call a top-level function, or array('classname', 'methodname') to call a static class member function, or array($classinstance, 'methodname') to call a class member function of an existing object, e.g. $this).

The callback functions should have a signature "function callbackName($args, $rule) {...}" and will be called when the rule is evaluated. The function arguments given in the rule are passed as an array to the callback function. Its second argument is the rule that is currently evaluated. In most cases there should be no need to access the $rule, except to print out $rule->rulestring in error messages to tell the user which rule caused the error.

Example:

function onVmShippingRulesRegisterCustomFunctions(&$cartvals, $cart, $products, $method, $cart_prices) {
    return array (
        // Entries are of the form "FunctionNameForRules" => "PHP function to be called"
        'customTestFunction' => 'toplevelFunction', // A top-level function
        'customTestFunctionMember' => array($this, 'custom_member_func') // Calls the custom_member_func of this plugin
    );
}

At top-level:

function toplevelFunction($args, $rule) {
    // $args is an array of all function arguments!
    JFactory::getApplication()->enqueueMessage(JText::sprintf("Evaluating function customTestFunction in rule '%s'", htmlentities($rule->rulestring)), 'warning');
    return count($args);
}

Demo Server

Support Forum

License

These plugins are licenced unter the GNU GPLv3.