diff --git a/rules_shipping_base.php b/rules_shipping_base.php index 1c4bb8c47558549680047f3cc6d08f7b1244f057..dd76eb991743ff70c73c184ded64a188da312e41 100644 --- a/rules_shipping_base.php +++ b/rules_shipping_base.php @@ -25,12 +25,12 @@ if (!class_exists ('vmPSPlugin')) { require(JPATH_VM_PLUGINS . DS . 'vmpsplugin.php'); } // Only declare the class once... -if (class_exists ('plgVmShipmentRules_Shipping_Base')) { +if (class_exists ('plgVmShipmentRules_Shipping_Base')) { return; } /** Shipping costs according to general rules. - * Supported Variables: Weight, ZIP, Amount, Products (1 for each product, even if multiple ordered), Articles + * Supported Variables: Weight, ZIP, Amount, Products (1 for each product, even if multiple ordered), Articles * Assignable variables: Shipping, Name */ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { @@ -408,21 +408,21 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { return $dimensions; } - /** Allow child classes to add additional variables for the rules + /** Allow child classes to add additional variables for the rules */ protected function addCustomCartValues (VirtueMartCart $cart, $cart_prices, &$values) { } protected function getCartValues (VirtueMartCart $cart, $method, $cart_prices) { $address = (($cart->ST == 0) ? $cart->BT : $cart->ST); $zip = trim($address['zip']); - $cartvals = array('zip'=>$zip, - 'zip1'=>substr($zip,0,1), - 'zip2'=>substr($zip,0,2), - 'zip3'=>substr($zip,0,3), - 'zip4'=>substr($zip,0,4), - 'zip5'=>substr($zip,0,5), - 'zip6'=>substr($zip,0,6), - 'articles'=>$this->getOrderArticles($cart), + $cartvals = array('zip'=>$zip, + 'zip1'=>substr($zip,0,1), + 'zip2'=>substr($zip,0,2), + 'zip3'=>substr($zip,0,3), + 'zip4'=>substr($zip,0,4), + 'zip5'=>substr($zip,0,5), + 'zip6'=>substr($zip,0,6), + 'articles'=>$this->getOrderArticles($cart), 'products'=>$this->getOrderProducts($cart), 'amount'=>$cart_prices['salesPrice'], 'amountWithTax'=>$cart_prices['salesPrice'], @@ -588,7 +588,7 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { } -if (class_exists ('ShippingRule')) { +if (class_exists ('ShippingRule')) { return; } @@ -667,7 +667,7 @@ class ShippingRule { $res = false; switch ($terms[1]) { case '<': $res = ($terms[0] < $terms[2]); break; - case '<=': + case '<=': case '=<': $res = ($terms[0] <= $terms[2]); break; case '==': $res = ($terms[0] == $terms[2]); break; case '!=': @@ -675,7 +675,7 @@ class ShippingRule { case '>=': case '=>': $res = ($terms[0] >= $terms[2]); break; case '>': $res = ($terms[0] > $terms[2]); break; - case '~': + case '~': $l=min(strlen($terms[0]), strlen($terms[2])); $res = (strncmp ($terms[0], $terms[2], $l) == 0); break; @@ -692,7 +692,7 @@ class ShippingRule { // We do not have the correct number of terms for chained comparisons, i.e. two terms leftover instead of one! JFactory::getApplication()->enqueueMessage(JText::sprintf('VMSHIPMENT_RULES_EVALUATE_UNKNOWN_ERROR', $this->rulestring), 'error'); return false; - } + } // All conditions were fulfilled, so we can return true return true; } @@ -735,14 +735,14 @@ class ShippingRule { case ' AND ': $res = true; foreach ($args as $a) { $res = ($res && $a); }; break; case 'in': $needle = array_shift($args); $res = in_array($needle, $args); break; - case '<': - case '<=': - case '=<': - case '==': + case '<': + case '<=': + case '=<': + case '==': case '!=': - case '<>': + case '<>': case '>=': - case '=>': + case '=>': case '>': case '~': $res = $this->evaluateComparison(array($args[0], $op, $args[1]), $vals); break; @@ -774,7 +774,7 @@ class ShippingRule { function matches($vals) { // First, check the country, if any conditions are given: - if (count ($this->countries) > 0 && !in_array ($vals['country'], $this->countries)) + if (count ($this->countries) > 0 && !in_array ($vals['country'], $this->countries)) return False; foreach ($this->conditions as $c) {