diff --git a/documents/ShippingByRules_Framework_API.txt b/documents/ShippingByRules_Framework_API.txt index 3d4c999ff28e5d0787b773ebd71481c48f8e2d40..ed685e3901737dd9980825fb16ddc6ca2fb24701 100644 --- a/documents/ShippingByRules_Framework_API.txt +++ b/documents/ShippingByRules_Framework_API.txt @@ -6,38 +6,45 @@ API functions: ~~~~~~~~~~~~~~ -) setup() // Used in the plugin's constructor -) registerCallback($callback, $func) + -) warning($text, $args...) + -) debug($text) - -) parseRuleSyntax($rulestring, $countries, $tax) - -) checkConditions ($cart, $method, $cart_prices) - -) getCosts($cart, $method, $cart_prices, $variables=null) // The central function to calculate the shipping cost + -) parseRuleSyntax($rulestring, $countries, $ruleinfo) + -) checkConditions ($cart, $method) + -) getCosts($cart, $method) // The central function to calculate the shipping cost -) getRuleName($methodid) -) getRuleVariables($methodid) - + -) filterProducts($products, $conditions) // Used in the Rule's evaluateScoping E-commerce specific functions (to be overridden in child classes!): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -) printWarning($message) - -) __($string) + -) printWarning($message) // $message already translated! + -) debug($message) + -) __($string) // or use the translate callback for your own function! -) getCustomFunctions() - -) addPluginCartValues($cart, $products, $method, $cart_prices, &$values) - - -) getOrderArticles($cart, $products) - -) getOrderProducts ($cart, $products) - -) getOrderDimensions ($cart, $products, $length_dimension) - -) getOrderWeights ($cart, $products, $weight_unit) - -) getOrderListProperties ($cart, $products) - -) getOrderAddress ($cart) - -) getOrderPrices ($cart, $products, $cart_prices) - + -) addPluginCartValues($cart, $products, $method, &$values) + + -) getOrderArticles($cart, $products, $method) + -) getOrderProducts ($cart, $products, $method) + -) getOrderDimensions ($cart, $products, $method) + -) getOrderWeights ($cart, $products, $method) + -) getOrderListProperties ($cart, $products, $method) + -) getOrderAddress ($cart, $method) + -) getOrderPrices ($cart, $products, $method) + -) filterProducts($products, $conditions) // Used in the Rule's evaluateScoping + -) getMethodId ($method) + -) getMethodName ($method) + + -) setMethodCosts($cart, $method, $match, $costs) // Potentially assign system-specific variables to the $method Callback functions: ~~~~~~~~~~~~~~~~~~~ -) translate($message) - -) initRule($framework, $rulestring, $countries, $tax) - -) addCustomCartValues ($cart, $products, $cart_prices, &$values) + -) initRule($framework, $rulestring, $countries, $ruleinfo) + -) addCustomCartValues ($cart, $products, $method, &$values) diff --git a/language/en-GB/en-GB.plg_vmshipment_rules_shipping.ini b/language/en-GB/en-GB.plg_vmshipment_rules_shipping.ini index 212401705c2c9c597ac14d5b03941c326de80fd7..0434c992395aed5a6fb5cdf2f714717f59970b69 100755 --- a/language/en-GB/en-GB.plg_vmshipment_rules_shipping.ini +++ b/language/en-GB/en-GB.plg_vmshipment_rules_shipping.ini @@ -2,66 +2,66 @@ ; Copyright (C) 20123Reinhold Kainhofer. All rights reserved. ; License http://www.gnu.org/licenses/gpl.html GNU/GPL ; Note : All ini files need to be saved as UTF-8 - No BOM -VMSHIPMENT_RULES="Shipping by Rules for VirtueMart" -VMSHIPMENT_RULES_DESC="" -VMSHIPMENT_RULES_ADV="Advanced Shipping by Rules for VirtueMart" -VMSHIPMENT_RULES_ADV_DESC="" +OTSHIPMENT_RULES="Shipping by Rules for VirtueMart" +OTSHIPMENT_RULES_DESC="" +OTSHIPMENT_RULES_ADV="Advanced Shipping by Rules for VirtueMart" +OTSHIPMENT_RULES_ADV_DESC="" -VMSHIPMENT_RULES_PLUGIN="<b>Shipment based on general rules (weight, products, amount) per country-zones</b>" -VMSHIPMENT_RULES_PLUGIN_ADV="<b>Shipment based on general rules (weight, products, amount) per country-zones, including arithmetic expression</b>" +OTSHIPMENT_RULES_PLUGIN="<b>Shipment based on general rules (weight, products, amount) per country-zones</b>" +OTSHIPMENT_RULES_PLUGIN_ADV="<b>Shipment based on general rules (weight, products, amount) per country-zones, including arithmetic expression</b>" -VMSHIPMENT_RULES_HELP="<div style='background: #F8F8F8; padding:5px; margin:3px; border: 3px dashed #DDDDDD;'><h2>Overview of the Rules Syntax</h2><ul><li>Each line contains one rule consisting of several <b>conditions and assignments in arbitrary order and separated by semicolons</b>. </li><li>The <b>first matching rule is used</b> to calculate the shipping costs. If its shipping cost is set to <tt>NoShipping</tt>, then this method will not offer any shipping at all.</li><li>All rule parts with <b>comparison operators (<, <=, =<, ==, !=, <>, >=, =>, >)</b> are conditions.</li><li> Supported <b>variables (case-insensitive)</b>: <b><tt>Amount</tt></b>, <b><tt>Weight</tt></b>, <b><tt>ZIP</tt></b>, <b><tt>Products</tt></b> (number of different products), <b><tt>Articles</tt></b> (counted with quantity), <b><tt>Volume</tt></b> (total volume of the order) and <b><tt>MinVolume</tt>, <tt>MinLength</tt>, <tt>MinWidth</tt>, <tt>MinHeight</tt></b> as well as the same variables with <tt>Max</tt> instead of <tt>Min</tt>.</li><li>A condition can consist of multiple chained comparisons.</li><li>All rule parts of the form <b><tt>[VARIABLE]=VALUE</tt> are assignments</b>, with <tt>[VARIABLE]</tt> being one of <b><tt>Name</tt></b> (optional name of the rule, displayed in the cart and invoice), <b><tt>Shipping</tt></b> (shipping cost without tax if the rule matches) and <b><tt>ShippingWithTax</tt></b> (shipping cost including taxes if the rule matches). The <tt>Shipping=</tt> can be left out (<tt>ShippingWithTax=</tt> can not be left out). I.e. a rule part consisting only of a numerical value is understood as net shipping cost without tax.</li></ul><p>EXAMPLE: A rule named "Europe" that sets shipping costs of 4.50 for order amounts from 50 to less than 100, and free shipping from 100€ on would be:</p><blockquote><tt>Name=Free Shipping; 100<=Amount; 0<br>Name=Europe; 50<=Amount<100; Shipping=4.50</tt></blockquote><p>See also the the <a href='http://open-tools.net/documentation/shipping-by-rules-plugins-for-virtuemart.html'>Plugin's documentation</a> and <a href='http://open-tools.net/component/content/article.html?id=46'>Rules Examples</a>.</p></div>" -VMSHIPMENT_RULES_HELP_ADV="<div style='background: #EEEEEE; padding: 5px; margin: 3px; border: 2px dashed #DDDDDD;'><h2>Overview of the Rules Syntax</h2><ul><li>Each line contains one rule consisting of several <strong>conditions and assignments in arbitrary order and separated by semicolons</strong>.</li><li>The <strong>first matching rule is used</strong> to calculate the shipping costs. If its shipping cost is set to <tt>NoShipping</tt>, then this method will not offer any shipping at all.</li><li>All rule parts with <strong>comparison operators (<, <=, =<, ==, !=, <>, >=, =>, >)</strong> are conditions.</li><li>Supported <strong>variables (case-insensitive)</strong>: <strong><tt>Amount</tt></strong>, <strong><tt>Weight</tt></strong>, <strong><tt>ZIP</tt></strong>, <strong><tt>Products</tt></strong> (number of different products), <strong><tt>Articles</tt></strong> (counted with quantity), <strong><tt>Volume</tt></strong> (total volume of the order) and <strong><tt>MinVolume</tt>, <tt>MinLength</tt>, <tt>MinWidth</tt>, <tt>MinHeight</tt></strong> as well as the same variables with <tt>Max</tt> instead of <tt>Min</tt>.</li><li>A condition can consist of multiple chained comparisons. In the advanced version, the OR operator is available.</li><li>All rule parts of the form <strong><tt>[VARIABLE]=VALUE</tt> are assignments</strong>; allowed variables are <strong><tt>Name</tt></strong> (of the rule), <strong><tt>Shipping</tt></strong> and <strong><tt>ShippingWithTax</tt></strong>. The '<tt>Shipping='</tt> can be left out.</li><li>In the advanced version, all expressions may contain <strong>arbitrary basic arithmetic expressions (+, -, *, /, %, ^ and parentheses)</strong> of the above variables and functions like max(..), min(..), round(..), ceil(..), floor(..), day(), month(), etc..</li><li><strong>Alphanumeric postal codes</strong> are supported by the variables <tt>UK_Outward, UK_Area, UK_District, UK_Subdistrict, Canada_FSA, Canada_Area, Canada_Urban, Canada_Subarea, ZIP1, ZIP2, ZIP3, ZIP4, ZIP5</tt> and <tt>ZIP6</tt> in the advanced version.</li></ul><p>EXAMPLE: A rule named 'Europe' that sets shipping costs of 5€ plus 1.50€ per article for order amounts from 50 to less than 100, and free shipping from 100€ on would be:</p><blockquote><tt>Name=Free Shipping; 100<= Amount; 0<br/>Name=Europe; 50<=Amount<100; Shipping=5+1.50*Articles</tt></blockquote><p>See also the the <a href='http://open-tools.net/documentation/shipping-by-rules-plugins-for-virtuemart.html'>Plugin's documentation</a> and <a href='http://open-tools.net/component/content/article.html?id=46'>Rules Examples</a>.</p></div>" +OTSHIPMENT_RULES_HELP="<div style='background: #F8F8F8; padding:5px; margin:3px; border: 3px dashed #DDDDDD;'><h2>Overview of the Rules Syntax</h2><ul><li>Each line contains one rule consisting of several <b>conditions and assignments in arbitrary order and separated by semicolons</b>. </li><li>The <b>first matching rule is used</b> to calculate the shipping costs. If its shipping cost is set to <tt>NoShipping</tt>, then this method will not offer any shipping at all.</li><li>All rule parts with <b>comparison operators (<, <=, =<, ==, !=, <>, >=, =>, >)</b> are conditions.</li><li> Supported <b>variables (case-insensitive)</b>: <b><tt>Amount</tt></b>, <b><tt>Weight</tt></b>, <b><tt>ZIP</tt></b>, <b><tt>Products</tt></b> (number of different products), <b><tt>Articles</tt></b> (counted with quantity), <b><tt>Volume</tt></b> (total volume of the order) and <b><tt>MinVolume</tt>, <tt>MinLength</tt>, <tt>MinWidth</tt>, <tt>MinHeight</tt></b> as well as the same variables with <tt>Max</tt> instead of <tt>Min</tt>.</li><li>A condition can consist of multiple chained comparisons.</li><li>All rule parts of the form <b><tt>[VARIABLE]=VALUE</tt> are assignments</b>, with <tt>[VARIABLE]</tt> being one of <b><tt>Name</tt></b> (optional name of the rule, displayed in the cart and invoice), <b><tt>Shipping</tt></b> (shipping cost without tax if the rule matches) and <b><tt>ShippingWithTax</tt></b> (shipping cost including taxes if the rule matches). The <tt>Shipping=</tt> can be left out (<tt>ShippingWithTax=</tt> can not be left out). I.e. a rule part consisting only of a numerical value is understood as net shipping cost without tax.</li></ul><p>EXAMPLE: A rule named "Europe" that sets shipping costs of 4.50 for order amounts from 50 to less than 100, and free shipping from 100€ on would be:</p><blockquote><tt>Name=Free Shipping; 100<=Amount; 0<br>Name=Europe; 50<=Amount<100; Shipping=4.50</tt></blockquote><p>See also the the <a href='http://open-tools.net/documentation/shipping-by-rules-plugins-for-virtuemart.html'>Plugin's documentation</a> and <a href='http://open-tools.net/component/content/article.html?id=46'>Rules Examples</a>.</p></div>" +OTSHIPMENT_RULES_HELP_ADV="<div style='background: #EEEEEE; padding: 5px; margin: 3px; border: 2px dashed #DDDDDD;'><h2>Overview of the Rules Syntax</h2><ul><li>Each line contains one rule consisting of several <strong>conditions and assignments in arbitrary order and separated by semicolons</strong>.</li><li>The <strong>first matching rule is used</strong> to calculate the shipping costs. If its shipping cost is set to <tt>NoShipping</tt>, then this method will not offer any shipping at all.</li><li>All rule parts with <strong>comparison operators (<, <=, =<, ==, !=, <>, >=, =>, >)</strong> are conditions.</li><li>Supported <strong>variables (case-insensitive)</strong>: <strong><tt>Amount</tt></strong>, <strong><tt>Weight</tt></strong>, <strong><tt>ZIP</tt></strong>, <strong><tt>Products</tt></strong> (number of different products), <strong><tt>Articles</tt></strong> (counted with quantity), <strong><tt>Volume</tt></strong> (total volume of the order) and <strong><tt>MinVolume</tt>, <tt>MinLength</tt>, <tt>MinWidth</tt>, <tt>MinHeight</tt></strong> as well as the same variables with <tt>Max</tt> instead of <tt>Min</tt>.</li><li>A condition can consist of multiple chained comparisons. In the advanced version, the OR operator is available.</li><li>All rule parts of the form <strong><tt>[VARIABLE]=VALUE</tt> are assignments</strong>; allowed variables are <strong><tt>Name</tt></strong> (of the rule), <strong><tt>Shipping</tt></strong> and <strong><tt>ShippingWithTax</tt></strong>. The '<tt>Shipping='</tt> can be left out.</li><li>In the advanced version, all expressions may contain <strong>arbitrary basic arithmetic expressions (+, -, *, /, %, ^ and parentheses)</strong> of the above variables and functions like max(..), min(..), round(..), ceil(..), floor(..), day(), month(), etc..</li><li><strong>Alphanumeric postal codes</strong> are supported by the variables <tt>UK_Outward, UK_Area, UK_District, UK_Subdistrict, Canada_FSA, Canada_Area, Canada_Urban, Canada_Subarea, ZIP1, ZIP2, ZIP3, ZIP4, ZIP5</tt> and <tt>ZIP6</tt> in the advanced version.</li></ul><p>EXAMPLE: A rule named 'Europe' that sets shipping costs of 5€ plus 1.50€ per article for order amounts from 50 to less than 100, and free shipping from 100€ on would be:</p><blockquote><tt>Name=Free Shipping; 100<= Amount; 0<br/>Name=Europe; 50<=Amount<100; Shipping=5+1.50*Articles</tt></blockquote><p>See also the the <a href='http://open-tools.net/documentation/shipping-by-rules-plugins-for-virtuemart.html'>Plugin's documentation</a> and <a href='http://open-tools.net/component/content/article.html?id=46'>Rules Examples</a>.</p></div>" -VMSHIPMENT_RULES_LOGOS="Logo" -VMSHIPMENT_RULES_LOGOS_DESC="Select the logo to be displayed for this shipping method." -VMSHIPMENT_RULES_WEIGHT_UNIT="Weight Unit" -VMSHIPMENT_RULES_WEIGHT_UNIT_DESC="The Weight Unit in which the Weight is given" -VMSHIPMENT_RULES_LENGTH_UNIT="Length Unit" -VMSHIPMENT_RULES_LENGTH_UNIT_DESC="The length unit, in which the length, width and heights are given, and from which the volume is calculated." +OTSHIPMENT_RULES_LOGOS="Logo" +OTSHIPMENT_RULES_LOGOS_DESC="Select the logo to be displayed for this shipping method." +OTSHIPMENT_RULES_WEIGHT_UNIT="Weight Unit" +OTSHIPMENT_RULES_WEIGHT_UNIT_DESC="The Weight Unit in which the Weight is given" +OTSHIPMENT_RULES_LENGTH_UNIT="Length Unit" +OTSHIPMENT_RULES_LENGTH_UNIT_DESC="The length unit, in which the length, width and heights are given, and from which the volume is calculated." -VMSHIPMENT_RULES_COUNTRIES1_LABEL="<b>Rules for country zone 1</b>" -VMSHIPMENT_RULES_COUNTRIES2_LABEL="<b>Rules for country zone 2</b>" -VMSHIPMENT_RULES_COUNTRIES3_LABEL="<b>Rules for country zone 3</b>" -VMSHIPMENT_RULES_COUNTRIES4_LABEL="<b>Rules for country zone 4</b>" -VMSHIPMENT_RULES_COUNTRIES5_LABEL="<b>Rules for country zone 5</b>" -VMSHIPMENT_RULES_COUNTRIES6_LABEL="<b>Rules for country zone 6</b>" -VMSHIPMENT_RULES_COUNTRIES7_LABEL="<b>Rules for country zone 7</b>" -VMSHIPMENT_RULES_COUNTRIES8_LABEL="<b>Rules for country zone 8</b>" -VMSHIPMENT_RULES_COUNTRIES="Countries" -VMSHIPMENT_RULES_COUNTRIES_DESC="Select the countries to which the following rules should be restricted. If left empty, the rules will apply to all countries." -VMSHIPMENT_RULES_TAX="Tax" -VMSHIPMENT_RULES_TAX_DESC="Tax methods applied to the shipping cost if any of the given rules matches." -VMSHIPMENT_RULES_RULES="Rules" -VMSHIPMENT_RULES_RULES_DESC="" +OTSHIPMENT_RULES_COUNTRIES1_LABEL="<b>Rules for country zone 1</b>" +OTSHIPMENT_RULES_COUNTRIES2_LABEL="<b>Rules for country zone 2</b>" +OTSHIPMENT_RULES_COUNTRIES3_LABEL="<b>Rules for country zone 3</b>" +OTSHIPMENT_RULES_COUNTRIES4_LABEL="<b>Rules for country zone 4</b>" +OTSHIPMENT_RULES_COUNTRIES5_LABEL="<b>Rules for country zone 5</b>" +OTSHIPMENT_RULES_COUNTRIES6_LABEL="<b>Rules for country zone 6</b>" +OTSHIPMENT_RULES_COUNTRIES7_LABEL="<b>Rules for country zone 7</b>" +OTSHIPMENT_RULES_COUNTRIES8_LABEL="<b>Rules for country zone 8</b>" +OTSHIPMENT_RULES_COUNTRIES="Countries" +OTSHIPMENT_RULES_COUNTRIES_DESC="Select the countries to which the following rules should be restricted. If left empty, the rules will apply to all countries." +OTSHIPMENT_RULES_TAX="Tax" +OTSHIPMENT_RULES_TAX_DESC="Tax methods applied to the shipping cost if any of the given rules matches." +OTSHIPMENT_RULES_RULES="Rules" +OTSHIPMENT_RULES_RULES_DESC="" -VMSHIPMENT_RULES_SHIPPING_NAME="Shipment Name" -VMSHIPMENT_RULES_WEIGHT="Order Weight" -VMSHIPMENT_RULES_ARTICLES="Articles/Products in Order" -VMSHIPMENT_RULES_COST="Shipment Cost" +OTSHIPMENT_RULES_SHIPPING_NAME="Shipment Name" +OTSHIPMENT_RULES_WEIGHT="Order Weight" +OTSHIPMENT_RULES_ARTICLES="Articles/Products in Order" +OTSHIPMENT_RULES_COST="Shipment Cost" -VMSHIPMENT_RULES_UNKNOWN_VARIABLE="Unknown variable '%s' in rule '%s'" -VMSHIPMENT_RULES_UNKNOWN_OPERATOR="Unknown operator '%s' in shipment rule '%s'" -VMSHIPMENT_RULES_PARSE_MISSING_PAREN="Error during parsing expression '%s': Opening parenthesis cannot be found!" -VMSHIPMENT_RULES_PARSE_PAREN_NOT_CLOSED="Error during parsing expression '%s': A parenthesis was not closed properly!" -VMSHIPMENT_RULES_PARSE_FUNCTION_NOT_CLOSED="Error during parsing expression '%s': A function call was not closed properly!" +OTSHIPMENT_RULES_UNKNOWN_VARIABLE="Unknown variable '%s' in rule '%s'" +OTSHIPMENT_RULES_UNKNOWN_OPERATOR="Unknown operator '%s' in shipment rule '%s'" +OTSHIPMENT_RULES_PARSE_MISSING_PAREN="Error during parsing expression '%s': Opening parenthesis cannot be found!" +OTSHIPMENT_RULES_PARSE_PAREN_NOT_CLOSED="Error during parsing expression '%s': A parenthesis was not closed properly!" +OTSHIPMENT_RULES_PARSE_FUNCTION_NOT_CLOSED="Error during parsing expression '%s': A function call was not closed properly!" -VMSHIPMENT_RULES_EVALUATE_NONNUMERIC="Encountered term '%s' during evaluation, that does not evaluate to a numeric value! (Full rule: '%s')" -VMSHIPMENT_RULES_EVALUATE_SYNTAXERROR="Syntax error during evaluation, RPN is not well formed! (Full rule: '%s')" -VMSHIPMENT_RULES_EVALUATE_UNKNOWN_OPERATOR="Unknown operator '%s' encountered during evaluation of rule '%s'." -VMSHIPMENT_RULES_EVALUATE_UNKNOWN_FUNCTION="Unknown function '%s' encountered during evaluation of rule '%s'." -VMSHIPMENT_RULES_EVALUATE_UNKNOWN_ERROR="Unknown error occurred during evaluation of rule '%s'." -VMSHIPMENT_RULES_EVALUATE_ASSIGNMENT_TOPLEVEL="Assignments are not allowed inside expressions (rule given was '%s')" -VMSHIPMENT_RULES_EVALUATE_UNKNOWN_VALUE="Evaluation yields unknown value while evaluating rule part '%s'." +OTSHIPMENT_RULES_EVALUATE_NONNUMERIC="Encountered term '%s' during evaluation, that does not evaluate to a numeric value! (Full rule: '%s')" +OTSHIPMENT_RULES_EVALUATE_SYNTAXERROR="Syntax error during evaluation, RPN is not well formed! (Full rule: '%s')" +OTSHIPMENT_RULES_EVALUATE_UNKNOWN_OPERATOR="Unknown operator '%s' encountered during evaluation of rule '%s'." +OTSHIPMENT_RULES_EVALUATE_UNKNOWN_FUNCTION="Unknown function '%s' encountered during evaluation of rule '%s'." +OTSHIPMENT_RULES_EVALUATE_UNKNOWN_ERROR="Unknown error occurred during evaluation of rule '%s'." +OTSHIPMENT_RULES_EVALUATE_ASSIGNMENT_TOPLEVEL="Assignments are not allowed inside expressions (rule given was '%s')" +OTSHIPMENT_RULES_EVALUATE_UNKNOWN_VALUE="Evaluation yields unknown value while evaluating rule part '%s'." -VMSHIPMENT_RULES_EVALUATE_LISTFUNCTION_ARGS="List function '%s' requires all arguments to be lists. (Full rule: '%s')" -VMSHIPMENT_RULES_EVALUATE_LISTFUNCTION_CONTAIN_ARGS="List function '%s' requires the first argument to be lists. (Full rule: '%s')" -VMSHIPMENT_RULES_EVALUATE_LISTFUNCTION_UNKNOWN="Unknown list function '%s' encountered. (Full rule: '%s')" +OTSHIPMENT_RULES_EVALUATE_LISTFUNCTION_ARGS="List function '%s' requires all arguments to be lists. (Full rule: '%s')" +OTSHIPMENT_RULES_EVALUATE_LISTFUNCTION_CONTAIN_ARGS="List function '%s' requires the first argument to be lists. (Full rule: '%s')" +OTSHIPMENT_RULES_EVALUATE_LISTFUNCTION_UNKNOWN="Unknown list function '%s' encountered. (Full rule: '%s')" -VMSHIPMENT_RULES_NOSHIPPING_MESSAGE="%s" +OTSHIPMENT_RULES_NOSHIPPING_MESSAGE="%s" -VMSHIPMENT_RULES_UNKNOWN_TYPE="Unknown rule type '%s' encountered for rule '%s'" +OTSHIPMENT_RULES_UNKNOWN_TYPE="Unknown rule type '%s' encountered for rule '%s'" -VMSHIPMENT_RULES_CUSTOMFUNCTIONS_NOARRAY="Definition of custom functions (returned by a vmshipmentrules plugin) is not a proper array. Ignoring." -VMSHIPMENT_RULES_CUSTOMFUNCTIONS_ALREADY_DEFINED="Custom function %s already defined. Ignoring this definition and using previous one." +OTSHIPMENT_RULES_CUSTOMFUNCTIONS_NOARRAY="Definition of custom functions (returned by a vmshipmentrules plugin) is not a proper array. Ignoring." +OTSHIPMENT_RULES_CUSTOMFUNCTIONS_ALREADY_DEFINED="Custom function %s already defined. Ignoring this definition and using previous one." diff --git a/language/en-GB/en-GB.plg_vmshipment_rules_shipping.sys.ini b/language/en-GB/en-GB.plg_vmshipment_rules_shipping.sys.ini index c596379a61983904635f5bc2bd5a45bf59315c11..0e40a17eba803148b85f13e4fd968d77fd4e00d9 100755 --- a/language/en-GB/en-GB.plg_vmshipment_rules_shipping.sys.ini +++ b/language/en-GB/en-GB.plg_vmshipment_rules_shipping.sys.ini @@ -2,7 +2,7 @@ ; Copyright (C) 20123Reinhold Kainhofer. All rights reserved. ; License http://www.gnu.org/licenses/gpl.html GNU/GPL ; Note : All ini files need to be saved as UTF-8 - No BOM -VMSHIPMENT_RULES="Shipping by Rules for VirtueMart" -VMSHIPMENT_RULES_DESC="" -VMSHIPMENT_RULES_ADV="Advanced Shipping by Rules for VirtueMart" -VMSHIPMENT_RULES_ADV_DESC="" +OTSHIPMENT_RULES="Shipping by Rules for VirtueMart" +OTSHIPMENT_RULES_DESC="" +OTSHIPMENT_RULES_ADV="Advanced Shipping by Rules for VirtueMart" +OTSHIPMENT_RULES_ADV_DESC="" diff --git a/library/rules_shipping_framework.php b/library/rules_shipping_framework.php index 271664f075ffef9e80f2ecfa4f09a48b2e655522..9a33f4d69757d13959876f8aa3e04891015dcf48 100644 --- a/library/rules_shipping_framework.php +++ b/library/rules_shipping_framework.php @@ -3,19 +3,14 @@ defined ('_JEXEC') or die('Restricted access'); /** - * Shipment plugin for general, rules-based shipments, like regular postal services with complex shipping cost structures + * Shipping By Rules Framework for general, rules-based shipments, like regular postal services with complex shipping cost structures * - * @package VirtueMart + * @package ShippingByRules e-commerce system-agnostic framework for shipping plugins. * @subpackage Plugins - shipment - * @copyright Copyright (C) 2004-2012 VirtueMart Team - All rights reserved. * @copyright Copyright (C) 2013 Reinhold Kainhofer, reinhold@kainhofer.com * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt - * VirtueMart is free software. This version may have been modified pursuant - * to the GNU General Public License, and as distributed it includes or - * is derivative of works licensed under the GNU General Public License or - * other free or open source software licenses. * - * @author Reinhold Kainhofer, based on the weight_countries shipping plugin by Valerie Isaksen + * @author Reinhold Kainhofer, Open Tools * */ // Only declare the class once... @@ -58,12 +53,9 @@ class RulesShippingFramework { // Store the parsed and possibly evaluated rules for each method (method ID is used as key) protected $rules = array(); protected $match = array(); - protected $last_cartvals = array(); - protected $last_rulename = ''; var $custom_functions = array (); function __construct() { -// $this->registerCallback('initRule', array($this, 'createMethodRule')); // $this->registerCallback('addCustomCartValues', array($this, 'addCustomCartValues')); } @@ -86,50 +78,129 @@ class RulesShippingFramework { } public function __($string) { + $args = func_get_args(); + switch ($string) { + case "OTSHIPMENT_RULES_CUSTOMFUNCTIONS_ALREADY_DEFINED": + $args[0]=""; break; + case "OTSHIPMENT_RULES_CUSTOMFUNCTIONS_NOARRAY": + $args[0]=""; break; + case "OTSHIPMENT_RULES_EVALUATE_ASSIGNMENT_TOPLEVEL": + $args[0]="Assignments are not allowed inside expressions (rule given was '%s')"; break; + case "OTSHIPMENT_RULES_EVALUATE_LISTFUNCTION_ARGS": + $args[0]="List function '%s' requires all arguments to be lists. (Full rule: '%s')"; break; + case "OTSHIPMENT_RULES_EVALUATE_LISTFUNCTION_CONTAIN_ARGS": + $args[0]="List function '%s' requires the first argument to be lists. (Full rule: '%s')"; break; + case "OTSHIPMENT_RULES_EVALUATE_LISTFUNCTION_UNKNOWN": + $args[0]="Unknown list function '%s' encountered. (Full rule: '%s')"; break; + case "OTSHIPMENT_RULES_EVALUATE_SYNTAXERROR": + $args[0]="Syntax error during evaluation, RPN is not well formed! (Full rule: '%s')"; break; + case "OTSHIPMENT_RULES_EVALUATE_UNKNOWN_ERROR": + $args[0]="Unknown error occurred during evaluation of rule '%s'."; break; + case "OTSHIPMENT_RULES_EVALUATE_UNKNOWN_FUNCTION": + $args[0]="Unknown function '%s' encountered during evaluation of rule '%s'."; break; + case "OTSHIPMENT_RULES_EVALUATE_UNKNOWN_VALUE": + $args[0]="Evaluation yields unknown value while evaluating rule part '%s'."; break; + case "OTSHIPMENT_RULES_NOSHIPPING_MESSAGE": + $args[0]=""; break; + case "OTSHIPMENT_RULES_PARSE_FUNCTION_NOT_CLOSED": + $args[0]="Error during parsing expression '%s': A function call was not closed properly!"; break; + case "OTSHIPMENT_RULES_PARSE_MISSING_PAREN": + $args[0]="Error during parsing expression '%s': Opening parenthesis cannot be found!"; break; + case "OTSHIPMENT_RULES_PARSE_PAREN_NOT_CLOSED": + $args[0]="Error during parsing expression '%s': A parenthesis was not closed properly!"; break; + case "OTSHIPMENT_RULES_UNKNOWN_OPERATOR": + $args[0]="Unknown operator '%s' in shipment rule '%s'"; break; + case "OTSHIPMENT_RULES_UNKNOWN_TYPE": + $args[0]=""; break; + case "OTSHIPMENT_RULES_UNKNOWN_VARIABLE": + $args[0]="Unknown variable '%s' in rule '%s'"; break; + } + if (isset($this->callbacks["translate"])) { - return $this->callbacks["translate"]($string); + return call_user_func_array($this->callbacks["translate"], $args); } else { - return $string; + if (count($args)>1) { + return call_user_func_array("sprintf", $args); + } else { + return $string; + } } } + /** @tag system-specific + * @function getCustomFunctions() + * Let other plugins add custom functions! + * This function is expected to return an array of the form: + * array ('functionname1' => 'function-to-be-called', + * 'functionname2' => array($classobject, 'memberfunc')), + * ...); + */ function getCustomFunctions() { - // Let other plugins add custom functions! - // This function is expected to return an array of the form: - // array ('functionname1' => 'function-to-be-called', - // 'functionname2' => array($classobject, 'memberfunc')), - // ...); return array (); } - /** - * Function printWarning: This needs to be overwritten in derived classes! + /** @tag system-specific + * @function printWarning() + * Print a warning in the system-specific way. + * @param $message the warning message to be printed (already properly translated) */ - public function printWarning($message) { - // TODO! + protected function printWarning($message) { + echo($message); } - function setup() { + /** @tag public-api + * @tag system-specific + * @function warning() + * Print a warning (to be translated) in the system-specific way. + * @param $message the warning message to be printed + * @param $args optional arguments to be inserted into the translated message in sprintf-style + */ + public function warning($message) { + $args = func_get_args(); + $msg = call_user_func_array(array($this, "__"), $args); + $this->printWarning($msg); + } + + /** @tag public-api + * @function debug() + * Print a debug message (untranslated) in the system-specific way. + * @param $message the debug message to be printed + */ + public function debug($message) { + } + + /** @tag public-api + * @function setup + * Initialize the framework. Currently this only sets up plugin-defined custom functions + */ + public function setup() { $custfuncdefs = $this->getCustomFunctions(); // Loop through the return values of all plugins: foreach ($custfuncdefs as $custfuncs) { if (empty($custfuncs)) continue; if (!is_array($custfuncs)) { - $this->printWarning(JText::sprintf('VMSHIPMENT_RULES_CUSTOMFUNCTIONS_NOARRAY')); + $this->warning('OTSHIPMENT_RULES_CUSTOMFUNCTIONS_NOARRAY'); } // Now loop through all custom function definitions of this plugin // If a function was registered before, print a warning and use the first definition foreach ($custfuncs as $fname => $func) { if (isset($this->custom_functions[$fname])) { - $this->printWarning(JText::sprintf('VMSHIPMENT_RULES_CUSTOMFUNCTIONS_ALREADY_DEFINED', $fname)); + $this->warning('OTSHIPMENT_RULES_CUSTOMFUNCTIONS_ALREADY_DEFINED', $fname); } else { - vmDebug("Defining custom function $fname"); + $this->debug("Defining custom function $fname"); $this->custom_functions[strtolower($fname)] = $func; } } } } + + protected function getMethodId($method) { + return 0; + } + protected function getMethodName($method) { + return ''; + } /** * Functions to calculate the cart variables: @@ -138,64 +209,57 @@ class RulesShippingFramework { * - getOrderDimensions */ /** Functions to calculate all the different variables for the given cart and given (sub)set of products in the cart */ - protected function getOrderArticles ($cart, $products) { - return 0; - } - - protected function getOrderProducts ($cart, $products) { - return count($products); + protected function getOrderCounts ($cart, $products, $method) { + return array('articles' => 0, 'products' => count($products)); } - protected function getOrderDimensions ($cart, $products, $length_dimension) { + protected function getOrderDimensions ($cart, $products, $method) { return array(); } - protected function getOrderWeights ($cart, $products, $weight_unit) { + protected function getOrderWeights ($cart, $products, $method) { return array(); } - protected function getOrderListProperties ($cart, $products) { + protected function getOrderListProperties ($cart, $products, $method) { return array(); } - protected function getOrderAddress ($cart) { + protected function getOrderAddress ($cart, $method) { return array(); } - protected function getOrderPrices ($cart, $products, $cart_prices) { + protected function getOrderPrices ($cart, $products, $method) { return array(); } /** Allow child classes to add additional variables for the rules or modify existing one */ - protected function addCustomCartValues ($cart, $products, $cart_prices, &$values) { + protected function addCustomCartValues ($cart, $products, $method, &$values) { if (isset($this->callbacks['addCustomCartValues'])) { - return $this->callbacks['addCustomCartValues']($cart, $products, $cart_prices, $values); + return $this->callbacks['addCustomCartValues']($cart, $products, $method, $values); } } - protected function addPluginCartValues($cart, $products, $method, $cart_prices, &$values) { + protected function addPluginCartValues($cart, $products, $method, &$values) { } - public function getCartValues ($cart, $products, $method, $cart_prices) { + public function getCartValues ($cart, $products, $method) { $cartvals = array_merge ( - array( - 'articles'=>$this->getOrderArticles($cart, $products), - 'products'=>$this->getOrderProducts($cart, $products), - ), + $this->getOrderCounts($cart, $products, $method), // Add the prices, optionally calculated from the products subset of the cart - $this->getOrderPrices ($cart, $products, $cart_prices), + $this->getOrderPrices ($cart, $products, $method), // Add 'skus', 'categories', 'vendors' variables: - $this->getOrderListProperties ($cart, $products), + $this->getOrderListProperties ($cart, $products, $method), // Add country / state variables: - $this->getOrderAddress ($cart), + $this->getOrderAddress ($cart, $method), // Add Total/Min/Max weight and dimension variables: - $this->getOrderWeights ($cart, $products, $method->weight_unit), - $this->getOrderDimensions ($cart, $products, $method->length_unit) + $this->getOrderWeights ($cart, $products, $method), + $this->getOrderDimensions ($cart, $products, $method) ); // Let child classes update the $cartvals array, or add new variables - $this->addCustomCartValues($cart, $products, $cart_prices, $cartvals); + $this->addCustomCartValues($cart, $products, $method, $cartvals); // Let custom plugins update the $cartvals array or add new variables - $this->addPluginCartValues($cart, $products, $method, $cart_prices, $cartvals); + $this->addPluginCartValues($cart, $products, $method, $cartvals); return $cartvals; } @@ -203,18 +267,24 @@ class RulesShippingFramework { /** This function evaluates all rules, one after the other until it finds a matching rule that * defines shipping costs (or uses NoShipping). If a modifier or definition is encountered, * its effect is stored, but the loop continues */ - protected function evaluateMethodRules ($cart, $method, $cart_prices) { - $id = $method->virtuemart_shipmentmethod_id; // TODO: Generalize to other ecommerce systems! - // $method->match will cache the matched rule and the modifiers + protected function evaluateMethodRules ($cart, $method) { + $id = $this->getMethodId($method); + // $this->match will cache the matched rule and the modifiers if (isset($this->match[$id])) { return $this->match[$id]; } else { // Evaluate all rules and find the matching ones (including modifiers and definitions!) - $cartvals = $this->getCartValues ($cart, $cart->products, $method, $cart_prices); - $result = array("rule"=>Null, "rule_name"=>"", "modifiers_add"=>array(), "modifiers_multiply"=>array(), "cartvals"=>$cartvals); + $cartvals = $this->getCartValues ($cart, $cart->products, $method); + $result = array( + "rule" => Null, + "rule_name" => "", + "modifiers_add"=> array(), + "modifiers_multiply" => array(), + "cartvals" => $cartvals, + ); // Pass a callback function to the rules to obtain the cartvals for a subset of the products $this_class = $this; - $cartvals_callback = function ($products) use ($this_class, $cart, $method, $cart_prices) { + $cartvals_callback = function ($products) use ($this_class, $cart, $method) { return $this_class->getCartValues ($cart, $products, $method, NULL); }; foreach ($this->rules[$id] as $r) { @@ -235,7 +305,7 @@ class RulesShippingFramework { $cartvals[strtolower($r->getRuleName())] = $r->getValue(); break; default: - $this->helper->printWarning(JText::sprintf('VMSHIPMENT_RULES_UNKNOWN_TYPE', $r->getType(), $r->rulestring)); + $this->warning('OTSHIPMENT_RULES_UNKNOWN_TYPE', $r->getType(), $r->rulestring); break; } } @@ -251,63 +321,70 @@ class RulesShippingFramework { } /** - * @param \VirtueMartCart $cart + * @param $cart * @param int $method - * @param array $cart_prices * @return bool */ - public function checkConditions ($cart, $method, $cart_prices) { - if (!isset($this->rules[$method->virtuemart_shipmentmethod_id])) + public function checkConditions ($cart, $method) { + $id = $this->getMethodId($method); + $name = $this->getMethodName($method); + if (!isset($this->rules[$id])) $this->parseMethodRules($method); - $match = $this->evaluateMethodRules ($cart, $method, $cart_prices); + $match = $this->evaluateMethodRules ($cart, $method); if ($match && !is_null ($match['rule'])) { - $method->rule_name = $match["rule_name"]; + $this->setMethodCosts($method, $match, null); // If NoShipping is set, this method should NOT offer any shipping at all, so return FALSE, otherwise TRUE // If the rule has a name, print it as warning (otherwise don't print anything) if ($match['rule']->isNoShipping()) { - if (!empty($method->rule_name)) - $this->helper->pringWarning(JText::sprintf('VMSHIPMENT_RULES_NOSHIPPING_MESSAGE', $method->rule_name)); - vmdebug('checkConditions '.$method->shipment_name.' indicates NoShipping for this method, specified by rule "'.$method->rule_name.'" ('.$match['rule']->rulestring.').'); + if (!empty($match["rule_name"])) + $this->warning('OTSHIPMENT_RULES_NOSHIPPING_MESSAGE', $match["rule_name"]); + $this->debug('checkConditions '.$name.' indicates NoShipping for this method, specified by rule "'.$match["rule_name"].'" ('.$match['rule']->rulestring.').'); return FALSE; } else { return TRUE; } } - vmdebug('checkConditions '.$method->shipment_name.' does not fulfill all conditions, no rule matches'); + $this->debug('checkConditions '.$name.' does not fulfill all conditions, no rule matches'); return FALSE; } + + /** + * @tag system-specific + */ + protected function setMethodCosts($method, $match, $costs) { + // Allow some system-specific code, e.g. setting some members of $method, etc. + } /** - * @param VirtueMartCart $cart + * @param $cart * @param $method - * @param $cart_prices * @return int */ - function getCosts (VirtueMartCart $cart, $method, $cart_prices) { - if (!isset($this->rules[$method->virtuemart_shipmentmethod_id])) + function getCosts ($cart, $method) { + $id = $this->getMethodId($method); + if (!isset($this->rules[$id])) $this->parseMethodRules($method); - $match = $this->evaluateMethodRules ($cart, $method, $cart_prices); + $match = $this->evaluateMethodRules ($cart, $method); if ($match) { $r = $match["rule"]; - vmdebug('Rule ' . $match["rule_name"] . ' ('.$r->rulestring.') matched.'); - $method->tax_id = $r->tax_id; - // TODO: Shall we include the name of the modifiers, too? - $method->rule_name = $match["rule_name"]; + $this->debug('Rule ' . $match["rule_name"] . ' ('.$r->rulestring.') matched.'); + // Final shipping costs are calculated as: // Shipping*ExtraShippingMultiplier + ExtraShippingCharge // with possibly multiple modifiers - $method->cost = $r->getShippingCosts(); + $cost = $r->getShippingCosts(); foreach ($match['modifiers_multiply'] as $modifier) { - $method->cost *= $modifier->getValue(); + $cost *= $modifier->getValue(); } foreach ($match['modifiers_add'] as $modifier) { - $method->cost += $modifier->getValue(); + $cost += $modifier->getValue(); } - $method->includes_tax = $r->includes_tax; - return $method->cost; + $this->setMethodCosts($method, $match, $cost); + + return $cost; } - vmdebug('getCosts '.$method->name.' does not return shipping costs'); + $this->debug('getCosts '.$this->getMethodName($method).' does not return shipping costs'); return 0; } @@ -327,43 +404,35 @@ class RulesShippingFramework { } } - protected function createMethodRule ($r, $countries, $tax) { + protected function createMethodRule ($r, $countries, $ruleinfo) { if (isset($this->callbacks['initRule'])) { - return $this->callbacks['initRule']($this, $r, $countries, $tax); + return $this->callbacks['initRule']($this, $r, $countries, $ruleinfo); } else { - return new ShippingRule($this, $r, $countries, $tax); + return new ShippingRule($this, $r, $countries, $ruleinfo); } } // Parse the rule and append all rules to the rule set of the current shipment method (country/tax are already included in the rule itself!) - private function parseMethodRule ($rulestring, $countries, $tax, &$method) { - foreach ($this->parseRuleSyntax($rulestring, $countries, $tax) as $r) { - $this->rules[$method->virtuemart_shipmentmethod_id][] = $r; + protected function parseMethodRule ($rulestring, $countries, $ruleinfo, &$method) { + $id = $this->getMethodId($method); + foreach ($this->parseRuleSyntax($rulestring, $countries, $ruleinfo) as $r) { + $this->rules[$id][] = $r; } } - public function parseRuleSyntax($rulestring, $countries, $tax) { + public function parseRuleSyntax($rulestring, $countries, $ruleinfo) { $result = array(); $rules1 = preg_split("/(\r\n|\n|\r)/", $rulestring); foreach ($rules1 as $r) { // Ignore empty lines if (empty($r)) continue; - $result[] = $this->createMethodRule ($r, $countries, $tax); + $result[] = $this->createMethodRule ($r, $countries, $ruleinfo); } return $result; } protected function parseMethodRules (&$method) { - if (!isset($this->rules[$method->virtuemart_shipmentmethod_id])) - $this->rules[$method->virtuemart_shipmentmethod_id] = array(); - $this->parseMethodRule ($method->rules1, $method->countries1, $method->tax_id1, $method); - $this->parseMethodRule ($method->rules2, $method->countries2, $method->tax_id2, $method); - $this->parseMethodRule ($method->rules3, $method->countries3, $method->tax_id3, $method); - $this->parseMethodRule ($method->rules4, $method->countries4, $method->tax_id4, $method); - $this->parseMethodRule ($method->rules5, $method->countries5, $method->tax_id5, $method); - $this->parseMethodRule ($method->rules6, $method->countries6, $method->tax_id6, $method); - $this->parseMethodRule ($method->rules7, $method->countries7, $method->tax_id7, $method); - $this->parseMethodRule ($method->rules8, $method->countries8, $method->tax_id8, $method); + $this->warning("parseMethodRules not reimplemented => No rules will be loaded!"); } /** Filter the given array of products and return only those that belong to the categories, manufacturers, @@ -389,19 +458,19 @@ class ShippingRule { var $shipping = 0; var $conditions = array(); var $countries = array(); - var $tax_id = 0; + var $ruleinfo = 0; var $includes_tax = 0; - function __construct ($framework, $rule, $countries, $tax_id) { + function __construct ($framework, $rule, $countries, $ruleinfo) { + $this->framework = $framework; if (is_array($countries)) { $this->countries = $countries; } elseif (!empty($countries)) { $this->countries[0] = $countries; } - $this->tax_id = $tax_id; + $this->ruleinfo = $ruleinfo; $this->rulestring = $rule; $this->parseRule($rule); - $this->framework=$framework; } protected function parseRule($rule) { @@ -423,7 +492,7 @@ class ShippingRule { case 'extrashippingmultiplier': $this->shipping = $value; $this->ruletype = 'modifiers_multiply'; break; // modifiers are also stored in the shipping member! case 'comment': break; // Completely ignore all comments! case 'condition': $this->conditions[] = $value; break; - default: JFactory::getApplication()->enqueueMessage(JText::sprintf('VMSHIPMENT_RULES_UNKNOWN_VARIABLE', $var, $rulepart), 'error'); + default: $this->framework->warning('OTSHIPMENT_RULES_UNKNOWN_VARIABLE', $var, $rulepart); } } @@ -434,7 +503,6 @@ class ShippingRule { // or followed by another letter) and then all arithmetic operators $re = '/\s*("[^"]*"|\'[^\']*\'|<=|=>|>=|=<|<>|!=|==|<|=|>)\s*/i'; $atoms = preg_split($re, $expression, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); - // JFactory::getApplication()->enqueueMessage("TOKENIZING '$expression' returns: <pre>".print_r($atoms,1)."</pre>", 'error'); return $atoms; } @@ -470,7 +538,7 @@ class ShippingRule { array_shift($atoms); array_shift($atoms); } else { - JFactory::getApplication()->enqueueMessage(JText::sprintf('VMSHIPMENT_RULES_UNKNOWN_OPERATOR', $atoms[1], $rulepart), 'error'); + $this->framework->warning('OTSHIPMENT_RULES_UNKNOWN_OPERATOR', $atoms[1], $rulepart); $atoms = array(); } } @@ -506,7 +574,7 @@ class ShippingRule { $res = (strncmp ($terms[0], $terms[2], $l) == 0); break; default: - JFactory::getApplication()->enqueueMessage(JText::sprintf('VMSHIPMENT_RULES_UNKNOWN_OPERATOR', $terms[1], $this->rulestring), 'error'); + $this->framework->warning('OTSHIPMENT_RULES_UNKNOWN_OPERATOR', $terms[1], $this->rulestring); $res = false; } @@ -517,7 +585,7 @@ class ShippingRule { } if (count($terms)>1) { // We do not have the correct number of terms for chained comparisons, i.e. two terms leftover instead of one! - JFactory::getApplication()->enqueueMessage(JText::sprintf('VMSHIPMENT_RULES_EVALUATE_UNKNOWN_ERROR', $this->rulestring), 'error'); + $this->framework->warning('OTSHIPMENT_RULES_EVALUATE_UNKNOWN_ERROR', $this->rulestring); return false; } // All conditions were fulfilled, so we can return true @@ -531,7 +599,7 @@ class ShippingRule { $allarrays = $allarrays && is_array($a); } if (!$allarrays) { - JFactory::getApplication()->enqueueMessage(JText::sprintf('VMSHIPMENT_RULES_EVALUATE_LISTFUNCTION_ARGS', $function, $this->rulestring), 'error'); + $this->framework->warning('OTSHIPMENT_RULES_EVALUATE_LISTFUNCTION_ARGS', $function, $this->rulestring); return false; } @@ -548,7 +616,7 @@ class ShippingRule { return !array_diff($args[1], $args[0]); break; case "list_equal": return array_unique($args[0])==array_unique($args[1]); break; default: - JFactory::getApplication()->enqueueMessage(JText::sprintf('VMSHIPMENT_RULES_EVALUATE_LISTFUNCTION_UNKNOWN', $function, $this->rulestring), 'error'); + $this->framework->warning('OTSHIPMENT_RULES_EVALUATE_LISTFUNCTION_UNKNOWN', $function, $this->rulestring); return false; } } @@ -556,7 +624,7 @@ class ShippingRule { protected function evaluateListContainmentFunction ($function, $args) { # First make sure that the first argument is a list: if (!is_array($args[0])) { - JFactory::getApplication()->enqueueMessage(JText::sprintf('VMSHIPMENT_RULES_EVALUATE_LISTFUNCTION_CONTAIN_ARGS', $function, $this->rulestring), 'error'); + $this->framework->warning('OTSHIPMENT_RULES_EVALUATE_LISTFUNCTION_CONTAIN_ARGS', $function, $this->rulestring); return false; } // Extract the array from the args, the $args varialbe will now only contain the elements to be checked: @@ -588,7 +656,7 @@ class ShippingRule { } return true; default: - JFactory::getApplication()->enqueueMessage(JText::sprintf('VMSHIPMENT_RULES_EVALUATE_LISTFUNCTION_UNKNOWN', $function, $this->rulestring), 'error'); + $this->framework->warning('OTSHIPMENT_RULES_EVALUATE_LISTFUNCTION_UNKNOWN', $function, $this->rulestring); return false; } } @@ -622,8 +690,8 @@ class ShippingRule { // Check if we have a custom function definition and use that if so. // This is done first to allow plugins to override even built-in functions! if (isset($this->plugin->custom_functions[$func])) { - vmDebug("Evaluating custom function $function, defined by a plugin"); - return call_user_func($this->plugin->custom_functions[$func], $args, $this); + $this->framework->debug("Evaluating custom function $function, defined by a plugin"); + return call_user_func_array($this->plugin->custom_functions[$func], $args, $this); } // Functions with no argument: @@ -693,7 +761,7 @@ class ShippingRule { // None of the built-in function // No known function matches => print an error, return 0 - JFactory::getApplication()->enqueueMessage(JText::sprintf('VMSHIPMENT_RULES_EVALUATE_UNKNOWN_FUNCTION', $function, $this->rulestring), 'error'); + $this->framework->warning('OTSHIPMENT_RULES_EVALUATE_UNKNOWN_FUNCTION', $function, $this->rulestring); return 0; } @@ -708,7 +776,7 @@ class ShippingRule { } elseif ($varname=='values_debug') { return print_r($vals,1); } else { - JFactory::getApplication()->enqueueMessage(JText::sprintf('VMSHIPMENT_RULES_EVALUATE_UNKNOWN_VALUE', $expr, $this->rulestring), 'error'); + $this->framework->warning('OTSHIPMENT_RULES_EVALUATE_UNKNOWN_VALUE', $expr, $this->rulestring); return null; } } @@ -802,11 +870,10 @@ class ShippingRule { default: $res = false; } -// JFactory::getApplication()->enqueueMessage("<pre>Result of ".print_r($expr,1)." is $res.</pre>", 'error'); return $res; } else { // Neither string nor numeric, nor operator... - JFactory::getApplication()->enqueueMessage(JText::sprintf('VMSHIPMENT_RULES_EVALUATE_UNKNOWN_VALUE', $expr, $this->rulestring), 'error'); + $this->framework->warning('OTSHIPMENT_RULES_EVALUATE_UNKNOWN_VALUE', $expr, $this->rulestring); return null; } } @@ -823,7 +890,7 @@ class ShippingRule { $this->match = False; // Default, set it to True below if all conditions match... // First, check the country, if any conditions are given: if (count ($this->countries) > 0 && !in_array ($vals['countryid'], $this->countries)) { -// vmdebug('Rule::matches: Country check failed: countryid='.print_r($vals['countryid'],1).', countries are: '.print_r($this->countries,1).'...'); +// $this->framework->debug('Rule::matches: Country check failed: countryid='.print_r($vals['countryid'],1).', countries are: '.print_r($this->countries,1).'...'); return; } @@ -841,8 +908,8 @@ class ShippingRule { $this->value = $this->calculateShipping($vals, $products, $cartvals_callback); // Evaluate the rule name as a translatable string with variables inserted: // Replace all {variable} tags in the name by the variables from $vals - $matches=array(); - $name=JText::_($this->name); + $matches = array(); + $name = $this->framework->__($this->name); preg_match_all('/{([A-Za-z0-9_]+)}/', $name, $matches); foreach ($matches[1] as $m) { @@ -865,13 +932,13 @@ class ShippingRule { function getRuleName() { if (!$this->evaluated) - vmDebug('WARNING: getRuleName called without prior evaluation of the rule, e.g. by calling rule->matches(...)'); + $this->framework->debug('WARNING: getRuleName called without prior evaluation of the rule, e.g. by calling rule->matches(...)'); return $this->rulename; } function getValue() { if (!$this->evaluated) - vmDebug('WARNING: getValue called without prior evaluation of the rule, e.g. by calling rule->matches(...)'); + $this->framework->debug('WARNING: getValue called without prior evaluation of the rule, e.g. by calling rule->matches(...)'); return $this->value; } function getShippingCosts() { @@ -888,8 +955,8 @@ class ShippingRule { /** Extend the shipping rules by allowing arbitrary mathematical expressions */ class ShippingRule_Advanced extends ShippingRule { - function __construct ($method, $rule, $countries, $tax_id) { - parent::__construct ($method, $rule, $countries, $tax_id); + function __construct ($framework, $rule, $countries, $ruleinfo) { + parent::__construct ($framework, $rule, $countries, $ruleinfo); } function tokenize_expression ($expression) { @@ -899,7 +966,7 @@ class ShippingRule_Advanced extends ShippingRule { // or followed by another letter) and then all arithmetic operators $re = '/\s*("[^"]*"|\'[^\']*\'|(?<![A-Za-z0-9])(?:OR|AND|IN)(?![A-Za-z0-9])|&&|<=|=>|>=|=<|<>|!=|==|<|=|>|~|\+|-|\*|\/|%|\(|\)|\^|,)\s*/i'; $atoms = preg_split($re, $expression, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); - // JFactory::getApplication()->enqueueMessage("TOKENIZING '$expression' returns: <pre>".print_r($atoms,1)."</pre>", 'error'); + // $this->framework->warning("TOKENIZING '$expression' returns: <pre>".print_r($atoms,1)."</pre>"); return $atoms; } @@ -1032,7 +1099,7 @@ class ShippingRule_Advanced extends ShippingRule { $out_stack[]=$op; // 6b) "normal" operators } else { // no ( and no operator, so the expression is wrong! - JFactory::getApplication()->enqueueMessage(JText::sprintf('VMSHIPMENT_RULES_PARSE_MISSING_PAREN', $rulepart), 'error'); + $this->framework->warning('OTSHIPMENT_RULES_PARSE_MISSING_PAREN', $rulepart); break; } } while (true); @@ -1092,13 +1159,13 @@ class ShippingRule_Advanced extends ShippingRule { while ($op=array_pop($stack)) { // Opening parentheses should not be found on the stack any more. That would mean a closing paren is missing! if ($op == "(") { - JFactory::getApplication()->enqueueMessage(JText::sprintf('VMSHIPMENT_RULES_PARSE_PAREN_NOT_CLOSED', $rulepart), 'error'); + $this->framework->warning('OTSHIPMENT_RULES_PARSE_PAREN_NOT_CLOSED', $rulepart); } else { array_push ($out_stack, $op); } } if (!empty($function_args)) { - JFactory::getApplication()->enqueueMessage(JText::sprintf('VMSHIPMENT_RULES_PARSE_FUNCTION_NOT_CLOSED', $rulepart), 'error'); + $this->framework->warning('OTSHIPMENT_RULES_PARSE_FUNCTION_NOT_CLOSED', $rulepart); } @@ -1131,7 +1198,7 @@ class ShippingRule_Advanced extends ShippingRule { } elseif (in_array($e, $unary_ops)) { // 4) unary operators // Operator => apply to the last value on the stack if (count($stack)<1) { // 4d) - JFactory::getApplication()->enqueueMessage(JText::sprintf('VMSHIPMENT_RULES_EVALUATE_SYNTAXERROR', $rulepart), 'error'); + $this->framework->warning('OTSHIPMENT_RULES_EVALUATE_SYNTAXERROR', $rulepart); array_push($stack, 0); continue; } @@ -1143,7 +1210,7 @@ class ShippingRule_Advanced extends ShippingRule { } elseif (isset($operators[$e])) { // 4) binary operators // Operator => apply to the last two values on the stack if (count($stack)<2) { // 4d) - JFactory::getApplication()->enqueueMessage(JText::sprintf('VMSHIPMENT_RULES_EVALUATE_SYNTAXERROR', $rulepart), 'error'); + $this->framework->warning('OTSHIPMENT_RULES_EVALUATE_SYNTAXERROR', $rulepart); array_push($stack, 0); continue; } @@ -1172,8 +1239,8 @@ class ShippingRule_Advanced extends ShippingRule { } // 5a) if (count($stack) != 1) { - JFactory::getApplication()->enqueueMessage(JText::sprintf('VMSHIPMENT_RULES_EVALUATE_UNKNOWN_ERROR', $rulepart), 'error'); - JFactory::getApplication()->enqueueMessage(JText::sprintf('Outstack: <pre>%s</pre>', print_r($out_stack,1)), 'error'); + $this->framework->warning('OTSHIPMENT_RULES_EVALUATE_UNKNOWN_ERROR', $rulepart); + $this->framework->warning('Outstack: <pre>%s</pre>', print_r($out_stack,1)); $stack = array (0); } @@ -1184,7 +1251,7 @@ class ShippingRule_Advanced extends ShippingRule { $this->handleAssignment ($res[1], $res[2], $rulepart); } else { // Assignment has to be top-level! - JFactory::getApplication()->enqueueMessage(JText::sprintf('VMSHIPMENT_RULES_EVALUATE_ASSIGNMENT_TOPLEVEL', $rulepart), 'error'); + $this->framework->warning('OTSHIPMENT_RULES_EVALUATE_ASSIGNMENT_TOPLEVEL', $rulepart); } } elseif ($is_condition) { // Comparisons are conditions $this->conditions[] = $res; @@ -1194,7 +1261,7 @@ class ShippingRule_Advanced extends ShippingRule { $this->ruletype = 'shipping'; $this->includes_tax = False; } -// JFactory::getApplication()->enqueueMessage("<pre>Rule part '$rulepart' (type $this->ruletype) parsed into (condition=".print_r($is_condition,1).", assignment=".print_r($is_assignment,1)."): ".print_r($res,1)."</pre>", 'error'); +// $this->framework->warning("<pre>Rule part '$rulepart' (type $this->ruletype) parsed into (condition=".print_r($is_condition,1).", assignment=".print_r($is_assignment,1)."): ".print_r($res,1)."</pre>"); } diff --git a/rules_shipping.xml b/rules_shipping.xml index f13b0b35c58cd6eeb7db8953894b6f08f2908619..d414b1ba0ed844b4ddaf3bf004c8d602b22653f3 100644 --- a/rules_shipping.xml +++ b/rules_shipping.xml @@ -1,13 +1,13 @@ <?xml version="1.0" encoding="UTF-8" ?> <extension version="2.5" type="plugin" group="vmshipment" method="upgrade"> - <name>VMSHIPMENT_RULES</name> + <name>OTSHIPMENT_RULES</name> <creationDate>2014-09-14</creationDate> <author>Reinhold Kainhofer</author> <authorUrl>http://www.open-tools.net</authorUrl> <copyright>Copyright (C) 2013-2014, Reinhold Kainhofer</copyright> <license>GPL v3+</license> <version>5.4</version> - <description>VMSHIPMENT_RULES_DESC</description> + <description>OTSHIPMENT_RULES_DESC</description> <files> <filename plugin="rules_shipping">rules_shipping.php</filename> <filename>rules_shipping_base.php</filename> @@ -24,65 +24,65 @@ <!-- VM 3.x support (fields rather than params): --> <vmconfig> <fields name="params" addfieldpath="/plugins/vmshipment/rules_shipping/fields"> - <fieldset name="shipment" label="VMSHIPMENT_RULES_PLUGIN" addfieldpath="/administrator/components/com_virtuemart/fields"> + <fieldset name="shipment" label="OTSHIPMENT_RULES_PLUGIN" addfieldpath="/administrator/components/com_virtuemart/fields"> <field type="vmcurl"/> - <field type="spacer" default="VMSHIPMENT_RULES_PLUGIN" level="level1"/> - <field name="shipment_logos" type="imagelist" label="VMSHIPMENT_RULES_LOGOS" - description="VMSHIPMENT_RULES_LOGOS_DESC" multiple="true" + <field type="spacer" default="OTSHIPMENT_RULES_PLUGIN" level="level1"/> + <field name="shipment_logos" type="imagelist" label="OTSHIPMENT_RULES_LOGOS" + description="OTSHIPMENT_RULES_LOGOS_DESC" multiple="true" directory="/images/stories/virtuemart/shipment" default="" hide_default="1" hide_none="1" stripext="0" exclude="^_" /> - <field name="weight_unit" type="vmweightunit" size="10" default="" label="VMSHIPMENT_RULES_WEIGHT_UNIT" description="VMSHIPMENT_RULES_WEIGHT_UNIT_DESC"/> - <field name="length_unit" type="vmlengthunit" size="10" default="" label="VMSHIPMENT_RULES_LENGTH_UNIT" description="VMSHIPMENT_RULES_LENGTH_UNIT_DESC"/> - <field type="vmtitle" default="" description='VMSHIPMENT_RULES_HELP' /> + <field name="weight_unit" type="vmweightunit" size="10" default="" label="OTSHIPMENT_RULES_WEIGHT_UNIT" description="OTSHIPMENT_RULES_WEIGHT_UNIT_DESC"/> + <field name="length_unit" type="vmlengthunit" size="10" default="" label="OTSHIPMENT_RULES_LENGTH_UNIT" description="OTSHIPMENT_RULES_LENGTH_UNIT_DESC"/> + <field type="vmtitle" default="" description='OTSHIPMENT_RULES_HELP' /> </fieldset> - <fieldset name="countryzone1" label="VMSHIPMENT_RULES_COUNTRIES1_LABEL"> - <field name="countries1" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <field name="tax_id1" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <field name="rules1" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> + <fieldset name="countryzone1" label="OTSHIPMENT_RULES_COUNTRIES1_LABEL"> + <field name="countries1" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <field name="tax_id1" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <field name="rules1" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> </fieldset> - <fieldset name="countryzone2" label="VMSHIPMENT_RULES_COUNTRIES2_LABEL"> - <field name="countries2" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <field name="tax_id2" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <field name="rules2" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> + <fieldset name="countryzone2" label="OTSHIPMENT_RULES_COUNTRIES2_LABEL"> + <field name="countries2" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <field name="tax_id2" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <field name="rules2" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> </fieldset> - <fieldset name="countryzone3" label="VMSHIPMENT_RULES_COUNTRIES3_LABEL"> - <field name="countries3" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <field name="tax_id3" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <field name="rules3" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> + <fieldset name="countryzone3" label="OTSHIPMENT_RULES_COUNTRIES3_LABEL"> + <field name="countries3" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <field name="tax_id3" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <field name="rules3" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> </fieldset> - <fieldset name="countryzone4" label="VMSHIPMENT_RULES_COUNTRIES4_LABEL"> - <field name="countries4" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <field name="tax_id4" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <field name="rules4" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> + <fieldset name="countryzone4" label="OTSHIPMENT_RULES_COUNTRIES4_LABEL"> + <field name="countries4" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <field name="tax_id4" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <field name="rules4" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> </fieldset> - <fieldset name="countryzone5" label="VMSHIPMENT_RULES_COUNTRIES5_LABEL"> - <field name="countries5" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <field name="tax_id5" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <field name="rules5" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> + <fieldset name="countryzone5" label="OTSHIPMENT_RULES_COUNTRIES5_LABEL"> + <field name="countries5" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <field name="tax_id5" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <field name="rules5" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> </fieldset> - <fieldset name="countryzone6" label="VMSHIPMENT_RULES_COUNTRIES6_LABEL"> - <field name="countries6" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <field name="tax_id6" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <field name="rules6" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> + <fieldset name="countryzone6" label="OTSHIPMENT_RULES_COUNTRIES6_LABEL"> + <field name="countries6" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <field name="tax_id6" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <field name="rules6" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> </fieldset> - <fieldset name="countryzone7" label="VMSHIPMENT_RULES_COUNTRIES7_LABEL"> - <field name="countries7" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <field name="tax_id7" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <field name="rules7" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> + <fieldset name="countryzone7" label="OTSHIPMENT_RULES_COUNTRIES7_LABEL"> + <field name="countries7" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <field name="tax_id7" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <field name="rules7" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> </fieldset> - <fieldset name="countryzone8" label="VMSHIPMENT_RULES_COUNTRIES8_LABEL"> - <field name="countries8" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <field name="tax_id8" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <field name="rules8" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> + <fieldset name="countryzone8" label="OTSHIPMENT_RULES_COUNTRIES8_LABEL"> + <field name="countries8" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <field name="tax_id8" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <field name="rules8" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> </fieldset> </fields> @@ -95,56 +95,56 @@ <params> <param type="vmjpluginwarning" /> - <param type="spacer" default='VMSHIPMENT_RULES_PLUGIN' level="level1" /> - <param name="shipment_logos" type="vmfiles" label="VMSHIPMENT_RULES_LOGOS" - description="VMSHIPMENT_RULES_LOGOS_DESC" + <param type="spacer" default='OTSHIPMENT_RULES_PLUGIN' level="level1" /> + <param name="shipment_logos" type="vmfiles" label="OTSHIPMENT_RULES_LOGOS" + description="OTSHIPMENT_RULES_LOGOS_DESC" directory="/images/stories/virtuemart/shipment" default="default" hide_default="1" hide_none="1" stripext="0" exclude="^_" /> - <param name="weight_unit" type="vmweightunit" size="10" default="" label="VMSHIPMENT_RULES_WEIGHT_UNIT" description="VMSHIPMENT_RULES_WEIGHT_UNIT_DESC"/> - <param name="length_unit" type="vmlengthunit" size="10" default="" label="VMSHIPMENT_RULES_LENGTH_UNIT" description="VMSHIPMENT_RULES_LENGTH_UNIT_DESC"/> - - <param type="rklabel" default='VMSHIPMENT_RULES_HELP' /> - - <param type="rklabel" default='VMSHIPMENT_RULES_COUNTRIES1_LABEL' /> - <param name="countries1" type="vmcountries" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <param name="tax_id1" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <param name="rules1" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> - - <param type="rklabel" default="VMSHIPMENT_RULES_COUNTRIES2_LABEL" /> - <param name="countries2" type="vmcountries" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <param name="tax_id2" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <param name="rules2" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> - - <param type="rklabel" default="VMSHIPMENT_RULES_COUNTRIES3_LABEL" /> - <param name="countries3" type="vmcountries" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <param name="tax_id3" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <param name="rules3" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> - - <param type="rklabel" default="VMSHIPMENT_RULES_COUNTRIES4_LABEL" /> - <param name="countries4" type="vmcountries" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <param name="tax_id4" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <param name="rules4" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> - - <param type="rklabel" default="VMSHIPMENT_RULES_COUNTRIES5_LABEL" /> - <param name="countries5" type="vmcountries" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <param name="tax_id5" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <param name="rules5" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> - - <param type="rklabel" default="VMSHIPMENT_RULES_COUNTRIES6_LABEL" /> - <param name="countries6" type="vmcountries" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <param name="tax_id6" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <param name="rules6" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> - - <param type="rklabel" default="VMSHIPMENT_RULES_COUNTRIES7_LABEL" /> - <param name="countries7" type="vmcountries" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <param name="tax_id7" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <param name="rules7" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> - - <param type="rklabel" default="VMSHIPMENT_RULES_COUNTRIES8_LABEL" /> - <param name="countries8" type="vmcountries" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <param name="tax_id8" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <param name="rules8" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> + <param name="weight_unit" type="vmweightunit" size="10" default="" label="OTSHIPMENT_RULES_WEIGHT_UNIT" description="OTSHIPMENT_RULES_WEIGHT_UNIT_DESC"/> + <param name="length_unit" type="vmlengthunit" size="10" default="" label="OTSHIPMENT_RULES_LENGTH_UNIT" description="OTSHIPMENT_RULES_LENGTH_UNIT_DESC"/> + + <param type="rklabel" default='OTSHIPMENT_RULES_HELP' /> + + <param type="rklabel" default='OTSHIPMENT_RULES_COUNTRIES1_LABEL' /> + <param name="countries1" type="vmcountries" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <param name="tax_id1" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <param name="rules1" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> + + <param type="rklabel" default="OTSHIPMENT_RULES_COUNTRIES2_LABEL" /> + <param name="countries2" type="vmcountries" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <param name="tax_id2" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <param name="rules2" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> + + <param type="rklabel" default="OTSHIPMENT_RULES_COUNTRIES3_LABEL" /> + <param name="countries3" type="vmcountries" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <param name="tax_id3" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <param name="rules3" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> + + <param type="rklabel" default="OTSHIPMENT_RULES_COUNTRIES4_LABEL" /> + <param name="countries4" type="vmcountries" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <param name="tax_id4" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <param name="rules4" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> + + <param type="rklabel" default="OTSHIPMENT_RULES_COUNTRIES5_LABEL" /> + <param name="countries5" type="vmcountries" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <param name="tax_id5" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <param name="rules5" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> + + <param type="rklabel" default="OTSHIPMENT_RULES_COUNTRIES6_LABEL" /> + <param name="countries6" type="vmcountries" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <param name="tax_id6" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <param name="rules6" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> + + <param type="rklabel" default="OTSHIPMENT_RULES_COUNTRIES7_LABEL" /> + <param name="countries7" type="vmcountries" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <param name="tax_id7" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <param name="rules7" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> + + <param type="rklabel" default="OTSHIPMENT_RULES_COUNTRIES8_LABEL" /> + <param name="countries8" type="vmcountries" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <param name="tax_id8" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <param name="rules8" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> </params> </extension> diff --git a/rules_shipping_advanced.php b/rules_shipping_advanced.php index b0e0653d17d92b4ecd38d4604c8ffc327347086e..d307879712ff932c26be26d6bbb8076dd9ad2d6c 100644 --- a/rules_shipping_advanced.php +++ b/rules_shipping_advanced.php @@ -27,8 +27,6 @@ if (!class_exists ('plgVmShipmentRules_Shipping_Base')) { } - - /** Shipping costs according to general rules. * Derived from the standard plugin, no need to change anything! The standard plugin already uses the advanced rules class defined below, if it can be found */ @@ -38,12 +36,12 @@ class plgVmShipmentRules_Shipping_Advanced extends plgVmShipmentRules_Shipping_B $this->helper->registerCallback('initRule', array($this, 'initRule')); $this->helper->registerCallback('addCustomCartValues', array($this, 'addCustomCartValues')); } - protected function initRule ($r, $countries, $tax) { - return new ShippingRule_Advanced ($this, $r, $countries, $tax); + public function initRule ($framework, $rulestring, $countries, $ruleinfo) { + return new ShippingRule_Advanced ($framework, $rulestring, $countries, $ruleinfo); } /** Allow child classes to add additional variables for the rules */ - protected function addCustomCartValues (VirtueMartCart $cart, $products, $cart_prices, &$values) { + public function addCustomCartValues ($cart, $products, $method, &$values) { $values['coupon'] = $cart->couponCode; // Postal code Check for UK postal codes: Use regexp to determine if ZIP structure matches and also to extract the parts. diff --git a/rules_shipping_advanced.xml b/rules_shipping_advanced.xml index 39b7ddd6128a68c37eb9ca2e92a6069eaa09c6bc..96d1b0cde191fa9134f6b3b8c5516e042d6e0e12 100644 --- a/rules_shipping_advanced.xml +++ b/rules_shipping_advanced.xml @@ -1,13 +1,13 @@ <?xml version="1.0" encoding="UTF-8" ?> <extension version="1.5" type="plugin" group="vmshipment" method="upgrade"> - <name>VMSHIPMENT_RULES_ADV</name> + <name>OTSHIPMENT_RULES_ADV</name> <creationDate>2014-09-14</creationDate> <author>Reinhold Kainhofer</author> <authorUrl>http://www.open-tools.net</authorUrl> <copyright>Copyright (C) 2013-2014, Reinhold Kainhofer</copyright> <license>GPL v3+</license> <version>5.4</version> - <description>VMSHIPMENT_RULES_ADV_DESC</description> + <description>OTSHIPMENT_RULES_ADV_DESC</description> <files> <filename plugin="rules_shipping_advanced">rules_shipping_advanced.php</filename> <filename>rules_shipping_base.php</filename> @@ -24,65 +24,65 @@ <!-- VM 3.0 support (fields rather than params): --> <vmconfig> <fields name="params" addfieldpath="/plugins/vmshipment/rules_shipping/fields"> - <fieldset name="shipment" label="VMSHIPMENT_RULES_PLUGIN_ADV" addfieldpath="/administrator/components/com_virtuemart/fields"> + <fieldset name="shipment" label="OTSHIPMENT_RULES_PLUGIN_ADV" addfieldpath="/administrator/components/com_virtuemart/fields"> <field type="vmcurl"/> - <field type="spacer" default="VMSHIPMENT_RULES_PLUGIN_ADV" level="level1"/> - <field name="shipment_logos" type="imagelist" label="VMSHIPMENT_RULES_LOGOS" - description="VMSHIPMENT_RULES_LOGOS_DESC" multiple="true" + <field type="spacer" default="OTSHIPMENT_RULES_PLUGIN_ADV" level="level1"/> + <field name="shipment_logos" type="imagelist" label="OTSHIPMENT_RULES_LOGOS" + description="OTSHIPMENT_RULES_LOGOS_DESC" multiple="true" directory="/images/stories/virtuemart/shipment" default="" hide_default="1" hide_none="1" stripext="0" exclude="^_" /> - <field name="weight_unit" type="vmweightunit" size="10" default="" label="VMSHIPMENT_RULES_WEIGHT_UNIT" description="VMSHIPMENT_RULES_WEIGHT_UNIT_DESC"/> - <field name="length_unit" type="vmlengthunit" size="10" default="" label="VMSHIPMENT_RULES_LENGTH_UNIT" description="VMSHIPMENT_RULES_LENGTH_UNIT_DESC"/> - <field type="vmtitle" default="" description='VMSHIPMENT_RULES_HELP_ADV' /> + <field name="weight_unit" type="vmweightunit" size="10" default="" label="OTSHIPMENT_RULES_WEIGHT_UNIT" description="OTSHIPMENT_RULES_WEIGHT_UNIT_DESC"/> + <field name="length_unit" type="vmlengthunit" size="10" default="" label="OTSHIPMENT_RULES_LENGTH_UNIT" description="OTSHIPMENT_RULES_LENGTH_UNIT_DESC"/> + <field type="vmtitle" default="" description='OTSHIPMENT_RULES_HELP_ADV' /> </fieldset> - <fieldset name="countryzone1" label="VMSHIPMENT_RULES_COUNTRIES1_LABEL"> - <field name="countries1" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <field name="tax_id1" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <field name="rules1" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> + <fieldset name="countryzone1" label="OTSHIPMENT_RULES_COUNTRIES1_LABEL"> + <field name="countries1" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <field name="tax_id1" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <field name="rules1" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> </fieldset> - <fieldset name="countryzone2" label="VMSHIPMENT_RULES_COUNTRIES2_LABEL"> - <field name="countries2" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <field name="tax_id2" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <field name="rules2" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> + <fieldset name="countryzone2" label="OTSHIPMENT_RULES_COUNTRIES2_LABEL"> + <field name="countries2" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <field name="tax_id2" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <field name="rules2" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> </fieldset> - <fieldset name="countryzone3" label="VMSHIPMENT_RULES_COUNTRIES3_LABEL"> - <field name="countries3" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <field name="tax_id3" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <field name="rules3" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> + <fieldset name="countryzone3" label="OTSHIPMENT_RULES_COUNTRIES3_LABEL"> + <field name="countries3" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <field name="tax_id3" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <field name="rules3" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> </fieldset> - <fieldset name="countryzone4" label="VMSHIPMENT_RULES_COUNTRIES4_LABEL"> - <field name="countries4" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <field name="tax_id4" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <field name="rules4" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> + <fieldset name="countryzone4" label="OTSHIPMENT_RULES_COUNTRIES4_LABEL"> + <field name="countries4" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <field name="tax_id4" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <field name="rules4" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> </fieldset> - <fieldset name="countryzone5" label="VMSHIPMENT_RULES_COUNTRIES5_LABEL"> - <field name="countries5" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <field name="tax_id5" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <field name="rules5" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> + <fieldset name="countryzone5" label="OTSHIPMENT_RULES_COUNTRIES5_LABEL"> + <field name="countries5" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <field name="tax_id5" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <field name="rules5" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> </fieldset> - <fieldset name="countryzone6" label="VMSHIPMENT_RULES_COUNTRIES6_LABEL"> - <field name="countries6" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <field name="tax_id6" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <field name="rules6" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> + <fieldset name="countryzone6" label="OTSHIPMENT_RULES_COUNTRIES6_LABEL"> + <field name="countries6" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <field name="tax_id6" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <field name="rules6" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> </fieldset> - <fieldset name="countryzone7" label="VMSHIPMENT_RULES_COUNTRIES7_LABEL"> - <field name="countries7" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <field name="tax_id7" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <field name="rules7" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> + <fieldset name="countryzone7" label="OTSHIPMENT_RULES_COUNTRIES7_LABEL"> + <field name="countries7" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <field name="tax_id7" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <field name="rules7" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> </fieldset> - <fieldset name="countryzone8" label="VMSHIPMENT_RULES_COUNTRIES8_LABEL"> - <field name="countries8" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <field name="tax_id8" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <field name="rules8" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> + <fieldset name="countryzone8" label="OTSHIPMENT_RULES_COUNTRIES8_LABEL"> + <field name="countries8" type="vmcountries" multiple="true" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <field name="tax_id8" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <field name="rules8" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> </fieldset> </fields> @@ -95,56 +95,56 @@ <params> <param type="vmjpluginwarning" /> - <param type="rklabel" default='VMSHIPMENT_RULES_PLUGIN_ADV' level="level1" /> - <param name="shipment_logos" type="vmfiles" label="VMSHIPMENT_RULES_LOGOS" - description="VMSHIPMENT_RULES_LOGOS_DESC" + <param type="rklabel" default='OTSHIPMENT_RULES_PLUGIN_ADV' level="level1" /> + <param name="shipment_logos" type="vmfiles" label="OTSHIPMENT_RULES_LOGOS" + description="OTSHIPMENT_RULES_LOGOS_DESC" directory="/images/stories/virtuemart/shipment" default="default" hide_default="1" hide_none="1" stripext="0" exclude="^_" /> - <param name="weight_unit" type="vmweightunit" size="10" default="" label="VMSHIPMENT_RULES_WEIGHT_UNIT" description="VMSHIPMENT_RULES_WEIGHT_UNIT_DESC"/> - <param name="length_unit" type="vmlengthunit" size="10" default="" label="VMSHIPMENT_RULES_LENGTH_UNIT" description="VMSHIPMENT_RULES_LENGTH_UNIT_DESC"/> - - <param type="rklabel" default='VMSHIPMENT_RULES_HELP_ADV' /> - - <param type="rklabel" default='VMSHIPMENT_RULES_COUNTRIES1_LABEL' /> - <param name="countries1" type="vmcountries" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <param name="tax_id1" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <param name="rules1" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> - - <param type="rklabel" default="VMSHIPMENT_RULES_COUNTRIES2_LABEL" /> - <param name="countries2" type="vmcountries" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <param name="tax_id2" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <param name="rules2" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> - - <param type="rklabel" default="VMSHIPMENT_RULES_COUNTRIES3_LABEL" /> - <param name="countries3" type="vmcountries" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <param name="tax_id3" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <param name="rules3" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> - - <param type="rklabel" default="VMSHIPMENT_RULES_COUNTRIES4_LABEL" /> - <param name="countries4" type="vmcountries" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <param name="tax_id4" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <param name="rules4" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> - - <param type="rklabel" default="VMSHIPMENT_RULES_COUNTRIES5_LABEL" /> - <param name="countries5" type="vmcountries" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <param name="tax_id5" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <param name="rules5" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> - - <param type="rklabel" default="VMSHIPMENT_RULES_COUNTRIES6_LABEL" /> - <param name="countries6" type="vmcountries" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <param name="tax_id6" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <param name="rules6" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> - - <param type="rklabel" default="VMSHIPMENT_RULES_COUNTRIES7_LABEL" /> - <param name="countries7" type="vmcountries" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <param name="tax_id7" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <param name="rules7" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> - - <param type="rklabel" default="VMSHIPMENT_RULES_COUNTRIES8_LABEL" /> - <param name="countries8" type="vmcountries" scope="com_virtuemart" default="" label="VMSHIPMENT_RULES_COUNTRIES" description="VMSHIPMENT_RULES_COUNTRIES_DESC"/> - <param name="tax_id8" type="vmtaxes" scope="com_virtuemart" label="VMSHIPMENT_RULES_TAX" description="VMSHIPMENT_RULES_TAX_DESC" /> - <param name="rules8" type="textarea" rows="6" cols="80" label="VMSHIPMENT_RULES_RULES" description="VMSHIPMENT_RULES_RULES_DESC" /> + <param name="weight_unit" type="vmweightunit" size="10" default="" label="OTSHIPMENT_RULES_WEIGHT_UNIT" description="OTSHIPMENT_RULES_WEIGHT_UNIT_DESC"/> + <param name="length_unit" type="vmlengthunit" size="10" default="" label="OTSHIPMENT_RULES_LENGTH_UNIT" description="OTSHIPMENT_RULES_LENGTH_UNIT_DESC"/> + + <param type="rklabel" default='OTSHIPMENT_RULES_HELP_ADV' /> + + <param type="rklabel" default='OTSHIPMENT_RULES_COUNTRIES1_LABEL' /> + <param name="countries1" type="vmcountries" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <param name="tax_id1" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <param name="rules1" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> + + <param type="rklabel" default="OTSHIPMENT_RULES_COUNTRIES2_LABEL" /> + <param name="countries2" type="vmcountries" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <param name="tax_id2" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <param name="rules2" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> + + <param type="rklabel" default="OTSHIPMENT_RULES_COUNTRIES3_LABEL" /> + <param name="countries3" type="vmcountries" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <param name="tax_id3" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <param name="rules3" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> + + <param type="rklabel" default="OTSHIPMENT_RULES_COUNTRIES4_LABEL" /> + <param name="countries4" type="vmcountries" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <param name="tax_id4" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <param name="rules4" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> + + <param type="rklabel" default="OTSHIPMENT_RULES_COUNTRIES5_LABEL" /> + <param name="countries5" type="vmcountries" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <param name="tax_id5" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <param name="rules5" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> + + <param type="rklabel" default="OTSHIPMENT_RULES_COUNTRIES6_LABEL" /> + <param name="countries6" type="vmcountries" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <param name="tax_id6" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <param name="rules6" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> + + <param type="rklabel" default="OTSHIPMENT_RULES_COUNTRIES7_LABEL" /> + <param name="countries7" type="vmcountries" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <param name="tax_id7" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <param name="rules7" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> + + <param type="rklabel" default="OTSHIPMENT_RULES_COUNTRIES8_LABEL" /> + <param name="countries8" type="vmcountries" scope="com_virtuemart" default="" label="OTSHIPMENT_RULES_COUNTRIES" description="OTSHIPMENT_RULES_COUNTRIES_DESC"/> + <param name="tax_id8" type="vmtaxes" scope="com_virtuemart" label="OTSHIPMENT_RULES_TAX" description="OTSHIPMENT_RULES_TAX_DESC" /> + <param name="rules8" type="textarea" rows="6" cols="80" label="OTSHIPMENT_RULES_RULES" description="OTSHIPMENT_RULES_RULES_DESC" /> </params> </extension> diff --git a/rules_shipping_base.php b/rules_shipping_base.php index 635eecc38d4c781de4775063722267f9c4c8e0b1..1c92cf0ec24ee2d28e7cc522e02d30c2816d42c2 100644 --- a/rules_shipping_base.php +++ b/rules_shipping_base.php @@ -119,7 +119,7 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { } // We need to call getCosts, because in J3 $method->rule_name and $method->cost as set in getCosts is no longer preserved. // Instead, we simply call getCosts again, which as a side-effect sets all those members of $method. - $costs = $this->helper->getCosts($cart,$method,$cart->cartPrices); + $costs = $this->helper->getCosts($cart,$method); $rulename = $this->helper->getRuleName($method->virtuemart_shipmentmethod_id); $variables = $this->helper->getRuleVariables($method->virtuemart_shipmentmethod_id); $values['virtuemart_order_id'] = $order['details']['BT']->virtuemart_order_id; @@ -201,6 +201,7 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { /** Include the rule name in the shipment name */ protected function renderPluginName ($plugin) { + $return = ''; $plugin_name = $this->_psType . '_name'; $plugin_desc = $this->_psType . '_desc'; diff --git a/rules_shipping_framework_joomla.php b/rules_shipping_framework_joomla.php index 74053e8b5da7abadd17b7eb74b220668cd613b36..c402dc1eaa1f70d8840d3d8a1d199e0c1f0d23a9 100644 --- a/rules_shipping_framework_joomla.php +++ b/rules_shipping_framework_joomla.php @@ -30,7 +30,7 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework { return array (); } - public function printWarning($message) { + protected function printWarning($message) { // Keep track of warning messages, so we don't print them twice: global $printed_warnings; if (!isset($printed_warnings)) @@ -40,6 +40,52 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework { $printed_warnings[] = $message; } } + /** @tag public-api + * @function debug() + * Print a debug message (untranslated) in the system-specific way. + * @param $message the debug message to be printed + */ + public function debug($message) { + vmDebug($message); + } + + public function __($string) { + $args = func_get_args(); + if (count($args)>1) { + return call_user_func_array(array("JText", "sprintf"), $args); + } else { + return call_user_func(array("JText", "_"), $string); + } + } + + protected function setMethodCosts($method, $match, $costs) { + $r = $match["rule"]; + // Allow some system-specific code, e.g. setting some members of $method, etc. + $method->tax_id = $r->ruleinfo['tax_id']; + // TODO: Shall we include the name of the modifiers, too? + $method->rule_name = $match["rule_name"]; + $method->cost = $costs; + $method->includes_tax = $r->includes_tax; + } + + protected function getMethodId($method) { + return $method->virtuemart_shipmentmethod_id; + } + + protected function getMethodName($method) { + return $method->shipment_name; + } + + protected function parseMethodRules (&$method) { + $this->parseMethodRule ($method->rules1, $method->countries1, array('tax_id'=>$method->tax_id1), $method); + $this->parseMethodRule ($method->rules2, $method->countries2, array('tax_id'=>$method->tax_id2), $method); + $this->parseMethodRule ($method->rules3, $method->countries3, array('tax_id'=>$method->tax_id3), $method); + $this->parseMethodRule ($method->rules4, $method->countries4, array('tax_id'=>$method->tax_id4), $method); + $this->parseMethodRule ($method->rules5, $method->countries5, array('tax_id'=>$method->tax_id5), $method); + $this->parseMethodRule ($method->rules6, $method->countries6, array('tax_id'=>$method->tax_id6), $method); + $this->parseMethodRule ($method->rules7, $method->countries7, array('tax_id'=>$method->tax_id7), $method); + $this->parseMethodRule ($method->rules8, $method->countries8, array('tax_id'=>$method->tax_id8), $method); + } /** * Functions to calculate the cart variables: @@ -48,19 +94,17 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework { * - getOrderDimensions */ /** Functions to calculate all the different variables for the given cart and given (sub)set of products in the cart */ - protected function getOrderArticles ($cart, $products) { + protected function getOrderCounts ($cart, $products, $method) { + $counts = array('products' => count($products)); $articles = 0; foreach ($products as $product) { $articles += $product->quantity; } - return $articles; - } - - protected function getOrderProducts ($cart, $products) { - return count($products); + $counts['articles'] = $articles; + return $counts; } - protected function getOrderDimensions ($cart, $products, $length_dimension) { + protected function getOrderDimensions ($cart, $products, $method) { /* Cache the value in a static variable and calculate it only once! */ $dimensions=array( 'volume' => 0, @@ -70,6 +114,7 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework { 'maxheight' => 0, 'minheight' => 9999999999, 'totalheight' => 0, 'maxpackaging' => 0, 'minpackaging' => 9999999999, 'totalpackaging' => 0, ); + $length_dimension = $method->length_unit; foreach ($products as $product) { $l = ShopFunctions::convertDimensionUnit ($product->product_length, $product->product_lwh_uom, $length_dimension); @@ -98,7 +143,8 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework { return $dimensions; } - protected function getOrderWeights ($cart, $products, $weight_unit) { + protected function getOrderWeights ($cart, $products, $method) { + $weight_unit = $method->weight_unit; $dimensions=array( 'weight' => 0, 'maxweight' => 0, 'minweight' => 9999999999, @@ -112,7 +158,7 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework { return $dimensions; } - protected function getOrderListProperties ($cart, $products) { + protected function getOrderListProperties ($cart, $products, $method) { $categories = array(); $vendors = array(); $skus = array(); @@ -138,11 +184,7 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework { ); } - protected function getOrderCountryState ($cart, $address) { - - } - - protected function getOrderAddress ($cart) { + protected function getOrderAddress ($cart, $method) { $address = (($cart->ST == 0 || $cart->STsameAsBT == 1) ? $cart->BT : $cart->ST); $zip = isset($address['zip'])?trim($address['zip']):''; $data = array('zip'=>$zip, @@ -207,7 +249,7 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework { return $data; } - protected function getOrderPrices ($cart, $products, $cart_prices) { + protected function getOrderPrices ($cart, $products, /*$cart_prices, */$method) { $data = array( 'amount' => 0, 'amountwithtax' => 0, @@ -221,20 +263,20 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework { 'discountamount' => 0, 'pricewithouttax' => 0, ); - if (!empty($cart_prices)) { - // get prices for the whole cart -> simply user the cart_prices - $data['amount'] = $cart_prices['salesPrice']; - $data['amountwithtax'] = $cart_prices['salesPrice']; - $data['amountwithouttax'] = $cart_prices['priceWithoutTax']; - $data['baseprice'] = $cart_prices['basePrice']; - $data['basepricewithtax'] = $cart_prices['basePriceWithTax']; - $data['discountedpricewithouttax'] = $cart_prices['discountedPriceWithoutTax']; - $data['salesprice'] = $cart_prices['salesPrice']; - $data['taxamount'] = $cart_prices['taxAmount']; - $data['salespricewithdiscount'] = $cart_prices['salesPriceWithDiscount']; - $data['discountamount'] = $cart_prices['discountAmount']; - $data['pricewithouttax'] = $cart_prices['priceWithoutTax']; - } else { +// if (!empty($cart_prices)) { +// // get prices for the whole cart -> simply user the cart_prices +// $data['amount'] = $cart_prices['salesPrice']; +// $data['amountwithtax'] = $cart_prices['salesPrice']; +// $data['amountwithouttax'] = $cart_prices['priceWithoutTax']; +// $data['baseprice'] = $cart_prices['basePrice']; +// $data['basepricewithtax'] = $cart_prices['basePriceWithTax']; +// $data['discountedpricewithouttax'] = $cart_prices['discountedPriceWithoutTax']; +// $data['salesprice'] = $cart_prices['salesPrice']; +// $data['taxamount'] = $cart_prices['taxAmount']; +// $data['salespricewithdiscount'] = $cart_prices['salesPriceWithDiscount']; +// $data['discountamount'] = $cart_prices['discountAmount']; +// $data['pricewithouttax'] = $cart_prices['priceWithoutTax']; +// } else { // Calculate the prices from the individual products! // Possible problems are discounts on the order total foreach ($products as $product) { @@ -250,18 +292,18 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework { $data['discountamount'] += $product->quantity*$product->allPrices[$product->selectedPrice]['discountAmount']; $data['pricewithouttax'] += $product->quantity*$product->allPrices[$product->selectedPrice]['priceWithoutTax']; } - } +// } return $data; } /** Allow child classes to add additional variables for the rules or modify existing one */ - protected function addCustomCartValues ($cart, $products, $cart_prices, &$values) { + protected function addCustomCartValues ($cart, $products, $method, &$values) { } - protected function addPluginCartValues($cart, $products, $method, $cart_prices, &$values) { + protected function addPluginCartValues($cart, $products, $method, &$values) { // Finally, call the triger of vmshipmentrules plugins to let them add/modify variables JPluginHelper::importPlugin('vmshipmentrules'); - JDispatcher::getInstance()->trigger('onVmShippingRulesGetCartValues',array(&$cartvals, $cart, $products, $method, $cart_prices)); + JDispatcher::getInstance()->trigger('onVmShippingRulesGetCartValues',array(&$cartvals, $cart, $products, $method)); } /** Filter the given array of products and return only those that belong to the categories, manufacturers,