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 8fa54ccba293d9c0bbb912df97b78996a094f450..696fe5f6cdc88ccbf074c0cc6f6ac48f10ba2fc9 100644 --- a/language/en-GB/en-GB.plg_vmshipment_rules_shipping.ini +++ b/language/en-GB/en-GB.plg_vmshipment_rules_shipping.ini @@ -10,8 +10,8 @@ VMSHIPMENT_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>" -VMSHIPMENT_RULES_HELP="<div style='background: #DDDDDD; padding:5px; margin:3px;'><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=Europe; 50<=Amount<100; Shipping=4.50<br>Name=Free Shipping; 100<= Amount; 0</tt></blockquote>><p>See also the the <a href="http://www.kainhofer.com/component/content/article/22-virtuemart-2-extensions/45-vm2-shipping-by-rules.html">Plugin's documentation</a> and <a href="http://www.kainhofer.com/component/content/article.html?id=46">Rules Examples</a>.</p></div>" -VMSHIPMENT_RULES_HELP_ADV="<div style="background: #DDDDDD; padding: 5px; margin: 3px;"><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.</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=Europe; 50<=Amount<100; Shipping=5+1.50*Articles<br />Name=Free Shipping; 100<= Amount; 0</tt></blockquote><p>See also the the <a href="http://www.kainhofer.com/component/content/article/22-virtuemart-2-extensions/45-vm2-shipping-by-rules.html">Plugin's documentation</a> and <a href="http://www.kainhofer.com/component/content/article.html?id=46">Rules Examples</a>.</p></div>" +VMSHIPMENT_RULES_HELP="<div style='background: #DDDDDD; padding:5px; margin:3px;'><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=Europe; 50<=Amount<100; Shipping=4.50<br>Name=Free Shipping; 100<= Amount; 0</tt></blockquote>><p>See also the the <a href='http://www.kainhofer.com/component/content/article/22-virtuemart-2-extensions/45-vm2-shipping-by-rules.html'>Plugin's documentation</a> and <a href='http://www.kainhofer.com/component/content/article.html?id=46'>Rules Examples</a>.</p></div>" +VMSHIPMENT_RULES_HELP_ADV="<div style='background: #DDDDDD; padding: 5px; margin: 3px;'><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.</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=Europe; 50<=Amount<100; Shipping=5+1.50*Articles<br />Name=Free Shipping; 100<= Amount; 0</tt></blockquote><p>See also the the <a href='http://www.kainhofer.com/component/content/article/22-virtuemart-2-extensions/45-vm2-shipping-by-rules.html'>Plugin's documentation</a> and <a href='http://www.kainhofer.com/component/content/article.html?id=46'>Rules Examples</a>.</p></div>" 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." diff --git a/releases/plg_vmshipment_rules_shipping_advanced_v2.4.0.zip b/releases/plg_vmshipment_rules_shipping_advanced_v2.4.0.zip index 18e60983b9389e085b55b6a0cb2e20b059fe7ea5..445a0b4d6bd1f57e5d36ba4dba222a46300608de 100644 Binary files a/releases/plg_vmshipment_rules_shipping_advanced_v2.4.0.zip and b/releases/plg_vmshipment_rules_shipping_advanced_v2.4.0.zip differ diff --git a/releases/plg_vmshipment_rules_shipping_v2.4.0.zip b/releases/plg_vmshipment_rules_shipping_v2.4.0.zip index 596526f6e3b02610930e5c53cca6b2ac83ad57f1..0fb4d8f0c560409900ad1a9102d14ff811b2b558 100644 Binary files a/releases/plg_vmshipment_rules_shipping_v2.4.0.zip and b/releases/plg_vmshipment_rules_shipping_v2.4.0.zip differ diff --git a/rules_shipping_advanced.php b/rules_shipping_advanced.php index 1b54814eb3b4ed111b2e0ca49daf90f1348fc800..42edbd3f65e36d337422b6c07d494b04e4062476 100644 --- a/rules_shipping_advanced.php +++ b/rules_shipping_advanced.php @@ -100,7 +100,7 @@ class ShippingRule_Advanced extends ShippingRule { function tokenize_expression ($expression) { // First, extract all strings, delimited by ": - $str_re = '/("(?:\\"|[^"])*"|\'(?:\\\'|[^\'])*\')/'; + $str_re = '/("[^"]*"|\'[^\']*\')/'; $strings = preg_split($str_re, $expression, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); // Then split all other parts of the expression at the operators $op_re = ':\s*( OR |&&| AND |<=|=>|>=|=>|<>|!=|==|<|=|>|~|\+|-|\*|/|%|\(|\)|\^)\s*:'; diff --git a/rules_shipping_base.php b/rules_shipping_base.php index 2f5ddf4120aef726e44a2e4397ba780dbe3a2487..afbc40c12e717b0fc18678cc8845c29fbe5a7f9d 100644 --- a/rules_shipping_base.php +++ b/rules_shipping_base.php @@ -404,7 +404,7 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { $products += 1; $articles += $product->quantity; } - $zip = $address['zip']; + $zip = trim($address['zip']); $cartvals = array('weight'=>$orderWeight, 'zip'=>$zip, 'zip1'=>substr($zip,0,1),