Commit 9e3dcb4f authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Make the VM plugin work with the library (nothing J/VM-specific in any more)

parent 6225f094
......@@ -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)
......@@ -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 (&lt;, &lt;=, =&lt;, ==, !=, &lt;&gt;, &gt;=, =&gt;, &gt;)</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 &quot;Europe&quot; 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&lt;=Amount; 0<br>Name=Europe; 50&lt;=Amount&lt;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 (&lt;, &lt;=, =&lt;, ==, !=, &lt;&gt;, &gt;=, =&gt;, &gt;)</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&lt;= Amount; 0<br/>Name=Europe; 50&lt;=Amount&lt;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 (&lt;, &lt;=, =&lt;, ==, !=, &lt;&gt;, &gt;=, =&gt;, &gt;)</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 &quot;Europe&quot; 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&lt;=Amount; 0<br>Name=Europe; 50&lt;=Amount&lt;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 (&lt;, &lt;=, =&lt;, ==, !=, &lt;&gt;, &gt;=, =&gt;, &gt;)</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&lt;= Amount; 0<br/>Name=Europe; 50&lt;=Amount&lt;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."
......@@ -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=""
This diff is collapsed.
This diff is collapsed.
......@@ -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.
......
This diff is collapsed.
......@@ -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';
......
......@@ -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,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment