From 809d6cf89ae593be6ae3a39cc622180f33432968 Mon Sep 17 00:00:00 2001
From: Reinhold Kainhofer <reinhold@kainhofer.com>
Date: Fri, 22 Nov 2013 16:54:31 +0100
Subject: [PATCH] Implement array comparisons so the order of the elements does
 not matter

---
 rules_shipping_base.php | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/rules_shipping_base.php b/rules_shipping_base.php
index 1bc990e..2c9ad6c 100644
--- a/rules_shipping_base.php
+++ b/rules_shipping_base.php
@@ -32,6 +32,13 @@ if (class_exists ('plgVmShipmentRules_Shipping_Base')) {
 // Keep track of warning messages, so we don't print them twice:
 $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.
  *  Supported Variables: Weight, ZIP, Amount, Products (1 for each product, even if multiple ordered), Articles
  *  Assignable variables: Shipping, Name
@@ -808,7 +815,7 @@ class ShippingRule {
 				case '<':  $res = ($terms[0] < $terms[2]);  break;
 				case '<=':
 				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 '<>': $res = ($terms[0] != $terms[2]); break;
 				case '>=':
@@ -824,6 +831,7 @@ class ShippingRule {
 			}
 
 			if ($res==false) return false;
+			// Remove the first operand and the operator from the comparison:
 			array_shift($terms);
 			array_shift($terms);
 		}
-- 
GitLab