diff --git a/app/code/community/Meanbee/Shippingrules/Model/Rule/Condition/Abstract.php b/app/code/community/Meanbee/Shippingrules/Model/Rule/Condition/Abstract.php index 9cdba7a..24b168f 100644 --- a/app/code/community/Meanbee/Shippingrules/Model/Rule/Condition/Abstract.php +++ b/app/code/community/Meanbee/Shippingrules/Model/Rule/Condition/Abstract.php @@ -14,7 +14,7 @@ public function getDefaultOperatorInputByType() { if (null === $this->_defaultOperatorInputByType) { $this->_defaultOperatorInputByType = array( - 'string' => array('==', '!=', '{}', '!{}', '^', '$', '!^', '!$', '()', '!()', '//'), + 'string' => array('==', '!=', '{}', '!{}', '^', '$', '!^', '!$', '()', '!()', '^()', '!^()', '//'), 'numeric' => array('==', '!=', '>=', '>', '<=', '<', '..', '!..', '()', '!()'), 'numeric_b26' => array('==', '!=', '>=:b26', '>:b26', '<=:b26', '<:b26', '..:b26', '!..:b26', '()', '!()'), 'numeric_b36' => array('==', '!=', '>=:b36', '>:b36', '<=:b36', '<:b36', '..:b36', '!..:b36', '()', '!()'), @@ -70,6 +70,8 @@ public function getDefaultOperatorOptions() '$' => Mage::helper('meanship')->__('ends with'), '!^' => Mage::helper('meanship')->__('does not begin with'), '!$' => Mage::helper('meanship')->__('does not end with'), + '^()' => Mage::helper('rule')->__('begins with one of'), + '!^()' => Mage::helper('rule')->__('does not begin with one of'), '//' => Mage::helper('meanship')->__('matches regex'), ); } @@ -86,7 +88,7 @@ public function getDefaultOperatorOptions() */ public function isArrayOperatorType() { $op = $this->getOperator(); - return $op === '()' || $op === '!()' || in_array($this->getInputType(), $this->_arrayInputTypes); + return $op === '()' || $op === '!()' || $op === '^()' || $op === '!^()' || in_array($this->getInputType(), $this->_arrayInputTypes); } /** @@ -350,6 +352,22 @@ public function validateAttribute($validatedValue) $result = (substr($validatedValue, -$length) === $value); } break; + + case '^()': case '!^()': + if (!is_string($validatedValue)) { + return false; + } else { + $value = (array)$value; + foreach ($value as $item) { + $length = strlen($item); + if (substr($validatedValue, 0, $length) === $item) { + $result = true; + break; + } + } + } + break; + case '//': if (Mage::helper('meanship')->isValidRegex($value)) { $result = (bool)preg_match($value, $validatedValue); @@ -357,7 +375,7 @@ public function validateAttribute($validatedValue) break; } - if (in_array($op, array('!=', '>', '<', '>:b26', '<:b26', '>:b36', '<:b36', '!..', '!..:b26', '!..:b36', '!{}', '!()', '!^', '!$'))) { + if (in_array($op, array('!=', '>', '<', '>:b26', '<:b26', '>:b36', '<:b36', '!..', '!..:b26', '!..:b36', '!{}', '!()', '!^', '!$', '!^()'))) { $result = !$result; } diff --git a/app/code/community/Meanbee/Shippingrules/etc/config.xml b/app/code/community/Meanbee/Shippingrules/etc/config.xml index abb3ad4..380313f 100644 --- a/app/code/community/Meanbee/Shippingrules/etc/config.xml +++ b/app/code/community/Meanbee/Shippingrules/etc/config.xml @@ -2,7 +2,7 @@ - 2.7.4 + 2.7.6 @@ -93,6 +93,7 @@ flag 1 1 + 0 diff --git a/app/code/community/Meanbee/Shippingrules/etc/system.xml b/app/code/community/Meanbee/Shippingrules/etc/system.xml index e8816d4..15b95e5 100644 --- a/app/code/community/Meanbee/Shippingrules/etc/system.xml +++ b/app/code/community/Meanbee/Shippingrules/etc/system.xml @@ -93,6 +93,26 @@ 1 1 + + + select + 100 + shipping-applicable-country + adminhtml/system_config_source_shipping_allspecificcountries + 1 + 1 + 0 + + + + multiselect + 101 + adminhtml/system_config_source_country + 1 + 1 + 0 + 1 + diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..3a9bce1 --- /dev/null +++ b/composer.json @@ -0,0 +1,15 @@ +{ + "name": "meanbee/magento-shipping-rules", + "description": "Magento 1 extension that uses the power of the promotion rules system to create flat rate shipping methods based on conditions", + "homepage": "https://www.meanbee.com/magento-extensions/meanbee-shipping-rules.html", + "type": "magento-module", + "authors": [ + { + "name": "Meanbee", + "email": "hello@meanbee.com" + } + ], + "require": { + "magento-hackathon/magento-composer-installer": "^3.0.0" + } +}