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

V1.2.1: Fix warning for rule lines that contain only spaces

parent 0d844af0
No related branches found
No related tags found
No related merge requests found
BASE=shipping-by-rules BASE=shipping-by-rules
PLATTFORM=woocommerce PLATTFORM=woocommerce
VENDOR=opentools VENDOR=opentools
VERSION=1.2 VERSION=1.2.1
DIR = $(shell pwd) DIR = $(shell pwd)
SVNDIR=wordpress-plugin-svn SVNDIR=wordpress-plugin-svn
......
...@@ -51,7 +51,7 @@ function is_equal($a, $b) { ...@@ -51,7 +51,7 @@ function is_equal($a, $b) {
class RulesShippingFramework { class RulesShippingFramework {
static $_version = "0.1"; static $_version = "0.1";
protected $_callbacks = array(); protected $callbacks = array();
// Store the parsed and possibly evaluated rules for each method (method ID is used as key) // Store the parsed and possibly evaluated rules for each method (method ID is used as key)
protected $rules = array(); protected $rules = array();
protected $match = array(); protected $match = array();
...@@ -294,7 +294,7 @@ class RulesShippingFramework { ...@@ -294,7 +294,7 @@ class RulesShippingFramework {
/** /**
* Extract information about non-numerical zip codes (UK and Canada) from the postal code * Extract information about non-numerical zip codes (UK and Canada) from the postal code
*/ */
protected function getAddressZIP ($zip) { public function getAddressZIP ($zip) {
$values = array(); $values = array();
// Postal code Check for UK postal codes: Use regexp to determine if ZIP structure matches and also to extract the parts. // Postal code Check for UK postal codes: Use regexp to determine if ZIP structure matches and also to extract the parts.
...@@ -334,11 +334,14 @@ class RulesShippingFramework { ...@@ -334,11 +334,14 @@ class RulesShippingFramework {
/** Allow child classes to add additional variables for the rules or modify existing one /** Allow child classes to add additional variables for the rules or modify existing one
*/ */
protected function addCustomCartValues ($cart, $products, $method, &$values) { protected function addCustomCartValues ($cart, $products, $method, &$values) {
// Pass all args through to the callback, if it exists
if (isset($this->callbacks['addCustomCartValues'])) { if (isset($this->callbacks['addCustomCartValues'])) {
return $this->callbacks['addCustomCartValues']($cart, $products, $method, $values); 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) { protected function addPluginCartValues($cart, $products, $method, &$values) {
return $values;
} }
public function getCartValues ($cart, $products, $method) { public function getCartValues ($cart, $products, $method) {
...@@ -535,7 +538,8 @@ class RulesShippingFramework { ...@@ -535,7 +538,8 @@ class RulesShippingFramework {
protected function createMethodRule ($r, $countries, $ruleinfo) { protected function createMethodRule ($r, $countries, $ruleinfo) {
if (isset($this->callbacks['initRule'])) { if (isset($this->callbacks['initRule'])) {
return $this->callbacks['initRule']($this, $r, $countries, $ruleinfo); return call_user_func_array($this->callbacks['initRule'],
array($this, $r, $countries, $ruleinfo));
} else { } else {
return new ShippingRule($this, $r, $countries, $ruleinfo); return new ShippingRule($this, $r, $countries, $ruleinfo);
} }
...@@ -554,7 +558,7 @@ class RulesShippingFramework { ...@@ -554,7 +558,7 @@ class RulesShippingFramework {
$rules1 = preg_split("/(\r\n|\n|\r)/", $rulestring); $rules1 = preg_split("/(\r\n|\n|\r)/", $rulestring);
foreach ($rules1 as $r) { foreach ($rules1 as $r) {
// Ignore empty lines // Ignore empty lines
if (empty($r)) continue; if (empty($r) || trim($r)=='') continue;
$result[] = $this->createMethodRule ($r, $countries, $ruleinfo); $result[] = $this->createMethodRule ($r, $countries, $ruleinfo);
} }
return $result; return $result;
......
...@@ -3,7 +3,7 @@ Contributors: opentools ...@@ -3,7 +3,7 @@ Contributors: opentools
Tags: WooCommerce, Shipment, Shipping Tags: WooCommerce, Shipment, Shipping
Requires at least: 4.0 Requires at least: 4.0
Tested up to: 4.4.1 Tested up to: 4.4.1
Stable tag: 1.1 Stable tag: 1.2.1
License: GPLv3 or later License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl.html License URI: http://www.gnu.org/licenses/gpl.html
......
...@@ -3,7 +3,7 @@ Contributors: opentools ...@@ -3,7 +3,7 @@ Contributors: opentools
Tags: WooCommerce, Shipment, Shipping, Rules shipping Tags: WooCommerce, Shipment, Shipping, Rules shipping
Requires at least: 4.0 Requires at least: 4.0
Tested up to: 4.4.2 Tested up to: 4.4.2
Stable tag: 1.2 Stable tag: 1.2.1
License: GPLv3 or later License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl.html License URI: http://www.gnu.org/licenses/gpl.html
...@@ -69,6 +69,9 @@ Please see our support forum at http://open-tools.net/forum/. It might also be a ...@@ -69,6 +69,9 @@ Please see our support forum at http://open-tools.net/forum/. It might also be a
== Changelog == == Changelog ==
= 1.2.1 =
* Fix for warning when a rule contained only spaces
= 1.2 = = 1.2 =
* Add support for "WC Vendors" and for "WooThemes Product Vendors" (new variable "Vendors", new function "evaluate_for_vendors") * Add support for "WC Vendors" and for "WooThemes Product Vendors" (new variable "Vendors", new function "evaluate_for_vendors")
......
File added
File added
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Plugin Name: WooCommerce Advanced Shipping By Rules * Plugin Name: WooCommerce Advanced Shipping By Rules
* Plugin URI: http://open-tools.net/woocommerce/advanced-shipping-by-rules-for-woocommerce.html * Plugin URI: http://open-tools.net/woocommerce/advanced-shipping-by-rules-for-woocommerce.html
* Description: Define Shipping cost by very general and flexible (text-based) rules. The advanced version also provides mathematical expressions and functions * Description: Define Shipping cost by very general and flexible (text-based) rules. The advanced version also provides mathematical expressions and functions
* Version: 1.2 * Version: 1.2.1
* Author: Open Tools, Reinhold Kainhofer * Author: Open Tools, Reinhold Kainhofer
* Author URI: http://open-tools.net * Author URI: http://open-tools.net
* Text Domain: woocommerce-advanced-shipping-by-rules * Text Domain: woocommerce-advanced-shipping-by-rules
...@@ -75,7 +75,7 @@ class WooCommerce_Shipping_By_Rules_Advanced { ...@@ -75,7 +75,7 @@ class WooCommerce_Shipping_By_Rules_Advanced {
* @since 1.0.0 * @since 1.0.0
* @var string $version Plugin version number. * @var string $version Plugin version number.
*/ */
public $version = '1.2'; public $version = '1.2.1';
/** /**
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Plugin Name: WooCommerce Shipping By Rules * Plugin Name: WooCommerce Shipping By Rules
* Plugin URI: http://open-tools.net/woocommerce/advanced-shipping-by-rules-for-woocommerce.html * Plugin URI: http://open-tools.net/woocommerce/advanced-shipping-by-rules-for-woocommerce.html
* Description: Define Shipping cost by very general and flexible (text-based) rules. * Description: Define Shipping cost by very general and flexible (text-based) rules.
* Version: 1.2 * Version: 1.2.1
* Author: Open Tools, Reinhold Kainhofer * Author: Open Tools, Reinhold Kainhofer
* Author URI: http://open-tools.net * Author URI: http://open-tools.net
* Text Domain: woocommerce-shipping-by-rules * Text Domain: woocommerce-shipping-by-rules
...@@ -48,7 +48,7 @@ class WooCommerce_Shipping_By_Rules { ...@@ -48,7 +48,7 @@ class WooCommerce_Shipping_By_Rules {
* @since 1.0.0 * @since 1.0.0
* @var string $version Plugin version number. * @var string $version Plugin version number.
*/ */
public $version = '1.2'; public $version = '1.2.1';
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment