diff --git a/Makefile b/Makefile index 14371bb5541e41dddbe02939dde81a713aa69029..70aac48a05386ce3921aa6cb988cc8d01cdb7131 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ BASE=rules_shipping BASE_ADV=rules_shipping_advanced PLUGINTYPE=vmshipment ZIPBASE=opentools_vm2 -VERSION=3.2 +VERSION=3.3 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/rules_shipping.xml b/rules_shipping.xml index 2c97179728e4f0243e43536d89176d8f17974552..cf9ab5cc8ba54021f7f4ea761448cd154fbe05b5 100644 --- a/rules_shipping.xml +++ b/rules_shipping.xml @@ -6,7 +6,7 @@ <authorUrl>http://www.open-tools.net</authorUrl> <copyright>Copyright (C) 2013, Reinhold Kainhofer</copyright> <license>GPL v3+</license> - <version>3.2</version> + <version>3.3</version> <description>VMSHIPMENT_RULES_DESC</description> <files> <filename plugin="rules_shipping">rules_shipping.php</filename> diff --git a/rules_shipping_advanced.php b/rules_shipping_advanced.php index a40fde60e7aa8cffad06d419a23c557fc8aff1e9..5a1610a65f42749c441482d4a2e58400696e0fc9 100644 --- a/rules_shipping_advanced.php +++ b/rules_shipping_advanced.php @@ -283,7 +283,7 @@ class ShippingRule_Advanced extends ShippingRule { while (count($stack)>0) { // 4a) $op = array_pop ($stack); // The only right-associative operator is =, which we allow at most once! - if ($op == "(") { + if ($op == "(" || $op == "FUNCTION(") { // add it back to the stack! array_push ($stack, $op); break; diff --git a/rules_shipping_advanced.xml b/rules_shipping_advanced.xml index 3357816f68009765db3c8123db51244a11261fce..4d14d9502777da0b82026afdab70ae4a2927fb0e 100644 --- a/rules_shipping_advanced.xml +++ b/rules_shipping_advanced.xml @@ -6,7 +6,7 @@ <authorUrl>http://www.open-tools.net</authorUrl> <copyright>Copyright (C) 2013, Reinhold Kainhofer</copyright> <license>GPL v3+</license> - <version>3.2</version> + <version>3.3</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 57fb8482320379ebdcefafc5e4c431712f7b0038..416113877eec82b32e9cc4153f3ba6bca018112a 100644 --- a/rules_shipping_base.php +++ b/rules_shipping_base.php @@ -431,22 +431,26 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { $countriesModel = VmModel::getModel('country'); if (isset($address['virtuemart_country_id'])) { + $data['countryid'] = $address['virtuemart_country_id']; $countriesModel->setId($address['virtuemart_country_id']); $country = $countriesModel->getData(); - $data['countryid'] = $country->virtuemart_country_id; - $data['country'] = $country->country_name; - $data['country2'] = $country->country_2_code; - $data['country3'] = $country->country_3_code; + if (isset($country)) { + $data['country'] = $country->country_name; + $data['country2'] = $country->country_2_code; + $data['country3'] = $country->country_3_code; + } } $statesModel = VmModel::getModel('state'); if (isset($address['virtuemart_state_id'])) { + $data['stateid'] = $address['virtuemart_state_id']; $statesModel->setId($address['virtuemart_state_id']); $state = $statesModel->getData(); - $data['stateid'] = $state->virtuemart_state_id; - $data['state'] = $state->state_name; - $data['state2'] = $state->state_2_code; - $data['state3'] = $state->state_3_code; + if (isset($state)) { + $data['state'] = $state->state_name; + $data['state2'] = $state->state_2_code; + $data['state3'] = $state->state_3_code; + } } return $data; @@ -483,6 +487,8 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { 'pricewithouttax'=>$cart_prices['priceWithoutTax'], 'skus'=>$this->getOrderSKUs($cart), + // TODO: Add 'categories' variable + // TODO: Add 'vendors'variable // 'discountbeforetaxbill'=>$cart_prices['discountBeforeTaxBill'], ); @@ -769,6 +775,7 @@ class ShippingRule { case "ceil": return ceil ($args[0]); break; case "floor": return floor($args[0]); break; case "abs": return abs($args[0]); break; + case "not": return !$args[0]; break; } } // Functions with variable number of args @@ -874,8 +881,10 @@ class ShippingRule { function matches($vals) { // First, check the country, if any conditions are given: - if (count ($this->countries) > 0 && !in_array ($vals['countryid'], $this->countries)) + 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).'...'); return False; + } foreach ($this->conditions as $c) { // All conditions have to match!