Skip to content
Snippets Groups Projects
Commit 5792cdfc authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Version 2.0.1: Add Total(Height|Width|Length), reduce log warnings

parent 61d615a8
No related branches found
No related tags found
No related merge requests found
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
......
File added
File added
......@@ -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>
......
......@@ -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>
......
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment