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

Implement array comparisons so the order of the elements does not matter

parent 2f0035a0
No related branches found
No related tags found
No related merge requests found
...@@ -32,6 +32,13 @@ if (class_exists ('plgVmShipmentRules_Shipping_Base')) { ...@@ -32,6 +32,13 @@ if (class_exists ('plgVmShipmentRules_Shipping_Base')) {
// Keep track of warning messages, so we don't print them twice: // Keep track of warning messages, so we don't print them twice:
$printed_warnings = array(); $printed_warnings = array();
function is_equal($a, $b) {
if (is_array($a) && is_array($b)) {
return !array_diff($a, $b) && !array_diff($b, $a);
} else {
return $a == $b;
}
}
/** Shipping costs according to general rules. /** 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 * Assignable variables: Shipping, Name
...@@ -808,7 +815,7 @@ class ShippingRule { ...@@ -808,7 +815,7 @@ class ShippingRule {
case '<': $res = ($terms[0] < $terms[2]); break; case '<': $res = ($terms[0] < $terms[2]); break;
case '<=': case '<=':
case '=<': $res = ($terms[0] <= $terms[2]); break; case '=<': $res = ($terms[0] <= $terms[2]); break;
case '==': $res = ($terms[0] == $terms[2]); break; case '==': $res = is_equal($terms[0], $terms[2]); break;
case '!=': case '!=':
case '<>': $res = ($terms[0] != $terms[2]); break; case '<>': $res = ($terms[0] != $terms[2]); break;
case '>=': case '>=':
...@@ -824,6 +831,7 @@ class ShippingRule { ...@@ -824,6 +831,7 @@ class ShippingRule {
} }
if ($res==false) return false; if ($res==false) return false;
// Remove the first operand and the operator from the comparison:
array_shift($terms); array_shift($terms);
array_shift($terms); array_shift($terms);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment