diff --git a/Makefile b/Makefile index 37b7df01ce870a207ed359c6f6609425f4125be9..dc6749191484694983dec566d9cc3f973757c1f8 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ BASE=rules_shipping BASE_ADV=rules_shipping_advanced PLUGINTYPE=vmshipment -VERSION=2.0 +VERSION=2.0.1 PLUGINFILES=$(BASE).php $(BASE)_base.php $(BASE).script.php $(BASE).xml index.html PLUGINFILES_ADV=$(BASE_ADV).php $(BASE)_base.php $(BASE_ADV).script.php $(BASE_ADV).xml index.html diff --git a/releases/plg_vmshipment_rules_shipping_advanced_v2.0.1.zip b/releases/plg_vmshipment_rules_shipping_advanced_v2.0.1.zip new file mode 100644 index 0000000000000000000000000000000000000000..6bc6af17af0829de73d382d795ea9fff76c7120b Binary files /dev/null and b/releases/plg_vmshipment_rules_shipping_advanced_v2.0.1.zip differ diff --git a/releases/plg_vmshipment_rules_shipping_v2.0.1.zip b/releases/plg_vmshipment_rules_shipping_v2.0.1.zip new file mode 100644 index 0000000000000000000000000000000000000000..d04a4b0a6dba865debb2fe19cd3ca31984589c84 Binary files /dev/null and b/releases/plg_vmshipment_rules_shipping_v2.0.1.zip differ diff --git a/rules_shipping.xml b/rules_shipping.xml index 3c30b2885c5285a9700d6957f45a1ca92ebc327a..b9d6a6242dd203985692b5ec900fbb423594f8e7 100644 --- a/rules_shipping.xml +++ b/rules_shipping.xml @@ -6,7 +6,7 @@ <authorUrl>http://www.kainhofer.com</authorUrl> <copyright>Copyright (C) 2013, Reinhold Kainhofer</copyright> <license>GPL v3+</license> - <version>2.0.0</version> + <version>2.0.1</version> <description>VMSHIPMENT_RULES_DESC</description> <files> <filename plugin="rules_shipping">rules_shipping.php</filename> diff --git a/rules_shipping_advanced.xml b/rules_shipping_advanced.xml index 278d8edabe6cf4524332cabf8c16cba5d7445eb8..3b2af1ec2dc3b6d7758c99ecce94c9b0ba916617 100644 --- a/rules_shipping_advanced.xml +++ b/rules_shipping_advanced.xml @@ -6,7 +6,7 @@ <authorUrl>http://www.kainhofer.com</authorUrl> <copyright>Copyright (C) 2013, Reinhold Kainhofer</copyright> <license>GPL v3+</license> - <version>2.0.0</version> + <version>2.0.1</version> <description>VMSHIPMENT_RULES_ADV_DESC</description> <files> <filename plugin="rules_shipping_advanced">rules_shipping_advanced.php</filename> diff --git a/rules_shipping_base.php b/rules_shipping_base.php index ca96df5cdfd720bd3461b5b9d35eb34f3aa72b22..0db9e39dbd2681ad84550d2a493ff6900e8d4e33 100644 --- a/rules_shipping_base.php +++ b/rules_shipping_base.php @@ -216,7 +216,7 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { * @return int */ function getCosts (VirtueMartCart $cart, $method, $cart_prices) { - if (empty($method->rules)) $this->parseMethodRules($method); + if (!isset($method->rules)) $this->parseMethodRules($method); $cartvals = $this->getCartValues ($cart, $method, $cart_prices); foreach ($method->rules as $r) { @@ -299,6 +299,7 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { } protected function parseMethodRules (&$method) { + if (!isset($method->rules)) $method->rules = 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); @@ -326,10 +327,10 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { static $dimensions=array( 'volume' => 0, 'maxvolume' => 0, 'minvolume' => 9999999999, - 'maxlength' => 0, 'minlength' => 9999999999, - 'maxwidth' => 0, 'minwidth' => 9999999999, - 'maxheight' => 0, 'minheight' => 9999999999, - ); + 'maxlength' => 0, 'minlength' => 9999999999, 'totallength' => 0, + 'maxwidth' => 0, 'minwidth' => 9999999999, 'totalwidth' => 0, + 'maxheight' => 0, 'minheight' => 9999999999, 'totalheight' => 0, + ); if ($calculated==0) { $calculated=1; foreach ($cart->products as $product) { @@ -343,6 +344,10 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { $dimensions['minwidth'] = min ($dimensions['minwidth'], $product->product_width); $dimensions['maxheight'] = max ($dimensions['maxheight'], $product->product_height); $dimensions['minheight'] = min ($dimensions['minheight'], $product->product_height); + $dimensions['totallength'] += $product->product_length; + $dimensions['totalwidth'] += $product->product_width; + $dimensions['totalheight'] += $product->product_height; + } } return $dimensions; @@ -405,7 +410,7 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { * @return bool */ protected function checkConditions ($cart, $method, $cart_prices) { - if (empty($method->rules)) $this->parseMethodRules($method); + if (!isset($method->rules)) $this->parseMethodRules($method); $cartvals = $this->getCartValues ($cart, $method, $cart_prices); foreach ($method->rules as $r) { @@ -513,20 +518,21 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { if (!empty($this->_psType) and !$this->selectedThis ($this->_psType, $name, $id)) { return FALSE; - } else { + } + if (isset($data['rules1'])) { // Try to parse all rules (and spit out error) to inform the user: $method = new StdClass (); - $this->parseMethodRule ($data['rules1'], $data['countries1'], $data['tax_id1'], $method); - $this->parseMethodRule ($data['rules2'], $data['countries2'], $data['tax_id2'], $method); - $this->parseMethodRule ($data['rules3'], $data['countries3'], $data['tax_id3'], $method); - $this->parseMethodRule ($data['rules4'], $data['countries4'], $data['tax_id4'], $method); - $this->parseMethodRule ($data['rules5'], $data['countries5'], $data['tax_id5'], $method); - $this->parseMethodRule ($data['rules6'], $data['countries6'], $data['tax_id6'], $method); - $this->parseMethodRule ($data['rules7'], $data['countries7'], $data['tax_id7'], $method); - $this->parseMethodRule ($data['rules8'], $data['countries8'], $data['tax_id8'], $method); - $ret=$this->setOnTablePluginParams ($name, $id, $table); - return $ret; + $this->parseMethodRule ($data['rules1'], isset($data['countries1'])?$data['countries1']:array(), $data['tax_id1'], $method); + $this->parseMethodRule ($data['rules2'], isset($data['countries2'])?$data['countries2']:array(), $data['tax_id2'], $method); + $this->parseMethodRule ($data['rules3'], isset($data['countries3'])?$data['countries3']:array(), $data['tax_id3'], $method); + $this->parseMethodRule ($data['rules4'], isset($data['countries4'])?$data['countries4']:array(), $data['tax_id4'], $method); + $this->parseMethodRule ($data['rules5'], isset($data['countries5'])?$data['countries5']:array(), $data['tax_id5'], $method); + $this->parseMethodRule ($data['rules6'], isset($data['countries6'])?$data['countries6']:array(), $data['tax_id6'], $method); + $this->parseMethodRule ($data['rules7'], isset($data['countries7'])?$data['countries7']:array(), $data['tax_id7'], $method); + $this->parseMethodRule ($data['rules8'], isset($data['countries8'])?$data['countries8']:array(), $data['tax_id8'], $method); } + $ret=$this->setOnTablePluginParams ($name, $id, $table); + return $ret; }