diff --git a/Makefile b/Makefile index 7a169e17f707178347cd96f35e4446d5815de663..a0008bc139c54927684c165e03cb9ec278aeebce 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ BASE=rules_shipping BASE_ADV=rules_shipping_advanced PLUGINTYPE=vmshipment ZIPBASE=opentools_vm -VERSION=6.1.2 +VERSION=6.1.3 PLUGINFILES=$(BASE).php $(BASE)_base.php $(BASE)_framework_joomla.php $(BASE).script.php $(BASE).xml index.html PLUGINFILES_ADV=$(BASE_ADV).php $(BASE)_base.php $(BASE)_framework_joomla.php $(BASE_ADV).script.php $(BASE_ADV).xml index.html diff --git a/library/rules_shipping_framework.php b/library/rules_shipping_framework.php index ea880ecd2b54654e905f73a9c51e99f3b4ad7f83..27f27c9b92c57ca6cb1fd46e399c85cd8152b049 100644 --- a/library/rules_shipping_framework.php +++ b/library/rules_shipping_framework.php @@ -294,7 +294,7 @@ class RulesShippingFramework { /** * Extract information about non-numerical zip codes (UK and Canada) from the postal code */ - protected function getAddressZIP ($zip) { + public function getAddressZIP ($zip) { $values = array(); // Postal code Check for UK postal codes: Use regexp to determine if ZIP structure matches and also to extract the parts. @@ -336,10 +336,12 @@ class RulesShippingFramework { protected function addCustomCartValues ($cart, $products, $method, &$values) { // Pass all args through to the callback, if it exists if (isset($this->callbacks['addCustomCartValues'])) { - return call_user_func_array($this->callbacks['addCustomCartValues'], func_get_args()); + return call_user_func_array($this->callbacks['addCustomCartValues'], array($cart, $products, $method, &$values)/*func_get_args()*/); } + return $values; } protected function addPluginCartValues($cart, $products, $method, &$values) { + return $values; } public function getCartValues ($cart, $products, $method) { diff --git a/releases/plg_opentools_vm_rules_shipping_advanced_v6.1.3.zip b/releases/plg_opentools_vm_rules_shipping_advanced_v6.1.3.zip new file mode 100644 index 0000000000000000000000000000000000000000..7169bd96b8dba083379f2d0db3dcd13e27f24c87 Binary files /dev/null and b/releases/plg_opentools_vm_rules_shipping_advanced_v6.1.3.zip differ diff --git a/releases/plg_opentools_vm_rules_shipping_v6.1.3.zip b/releases/plg_opentools_vm_rules_shipping_v6.1.3.zip new file mode 100644 index 0000000000000000000000000000000000000000..41a542703d7b1d61b3e99013c0c66edf525d0989 Binary files /dev/null and b/releases/plg_opentools_vm_rules_shipping_v6.1.3.zip differ diff --git a/rules_shipping.xml b/rules_shipping.xml index f15f0c05d0dd187a9e4ae4be2e0738fda18f5b60..b7e3fe65ceb0d706bd55d8424a43ea5c80048da6 100644 --- a/rules_shipping.xml +++ b/rules_shipping.xml @@ -6,7 +6,7 @@ <authorUrl>http://www.open-tools.net</authorUrl> <copyright>Copyright (C) 2013-2014, Reinhold Kainhofer</copyright> <license>GPL v3+</license> - <version>6.1.2</version> + <version>6.1.3</version> <description>OTSHIPMENT_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 dc6dd2195dad73f5e55497fd11566f1bef4d3738..937a6bc29fa3fd6e99baa620cffd15f60f953a15 100644 --- a/rules_shipping_advanced.php +++ b/rules_shipping_advanced.php @@ -34,49 +34,21 @@ class plgVmShipmentRules_Shipping_Advanced extends plgVmShipmentRules_Shipping_B function __construct (& $subject, $config) { parent::__construct ($subject, $config); $this->helper->registerCallback('initRule', array($this, 'initRule')); - $this->helper->registerCallback('addCustomCartValues', array($this, 'addCustomCartValues')); + $this->helper->registerCallback('addCustomCartValues', array($this, 'addAdvancedCustomCartValues')); } 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 */ - public function addCustomCartValues ($cart, $products, $method, &$values) { + public function addAdvancedCustomCartValues ($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. - // Also handle UK overseas areas/islands that use four-letter outward codes rather than "A{1,2}0{1,2}A{0,1} 0AA" + if (isset($values['zip'])) { $zip=strtoupper($values['zip']); } - if (isset($zip) and preg_match('/^\s*(([A-Z]{1,2})(\d{1,2})([A-Z]?)|[A-Z]{4}|GIR)\s*(\d[A-Z]{2})\s*$/', $zip, $match)) { - $values['uk_outward'] = $match[1]; - $values['uk_area'] = $match[2]; - $values['uk_district'] = $match[3]; - $values['uk_subdistrict'] = $match[4]; - $values['uk_inward'] = $match[5]; - } else { - $values['uk_outward'] = NULL; - $values['uk_area'] = NULL; - $values['uk_district'] = NULL; - $values['uk_subdistrict'] = NULL; - $values['uk_inward'] = NULL; - } - // Postal code Check for Canadian postal codes: Use regexp to determine if ZIP structure matches and also to extract the parts. - if (isset($zip) and preg_match('/^\s*(([A-Za-z])(\d)([A-Za-z]))\s*(\d[A-Za-z]\d)\s*$/', $zip, $match)) { - $values['canada_fsa'] = $match[1]; - $values['canada_area'] = $match[2]; - $values['canada_urban'] = $match[3]; - $values['canada_subarea'] = $match[4]; - $values['canada_ldu'] = $match[5]; - } else { - $values['canada_fsa'] = NULL; - $values['canada_area'] = NULL; - $values['canada_urban'] = NULL; - $values['canada_subarea'] = NULL; - $values['canada_ldu'] = NULL; - } - // print("<pre>values: ".print_r($values,1)."</pre>"); + $values = array_replace($values, $this->helper->getAddressZIP($zip)); + return $values; } /** diff --git a/rules_shipping_advanced.xml b/rules_shipping_advanced.xml index b3524b7c0dc7cb3c1a037473e877d8b3d2c60ab9..3cf7455224e1c59ce1d3fb15716b6134d9fedc93 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-2014, Reinhold Kainhofer</copyright> <license>GPL v3+</license> - <version>6.1.2</version> + <version>6.1.3</version> <description>OTSHIPMENT_RULES_ADV_DESC</description> <files> <filename plugin="rules_shipping_advanced">rules_shipping_advanced.php</filename> diff --git a/rules_shipping_framework_joomla.php b/rules_shipping_framework_joomla.php index 17af8e39f5b917905308e7cb2f12f72f46233eff..ff29c9eb6e58d0d64928e53783577d7001dab69c 100644 --- a/rules_shipping_framework_joomla.php +++ b/rules_shipping_framework_joomla.php @@ -325,8 +325,6 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework { /** Allow child classes to add additional variables for the rules or modify existing one */ - protected function addCustomCartValues ($cart, $products, $method, &$values) { - } protected function addPluginCartValues($cart, $products, $method, &$values) { // Finally, call the triger of vmshipmentrules plugins to let them add/modify variables JPluginHelper::importPlugin('vmshipmentrules');