From 52ae894ee26a6b3b8ae90c19051d8362c15877a5 Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer <reinhold@kainhofer.com> Date: Tue, 14 Jul 2015 01:08:02 +0300 Subject: [PATCH] Fix evaluate_for_skus/evaluate_for_products --- library/rules_shipping_framework.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/library/rules_shipping_framework.php b/library/rules_shipping_framework.php index ce7118b..5fc8fae 100644 --- a/library/rules_shipping_framework.php +++ b/library/rules_shipping_framework.php @@ -673,8 +673,8 @@ class ShippingRule { $filterkeys = array( "evaluate_for_categories" => 'categories', - "evaluate_for_products" => 'products', - "evaluate_for_skus" => 'products', + "evaluate_for_products" => 'skus', + "evaluate_for_skus" => 'skus', "evaluate_for_vendors" => 'vendors', "evaluate_for_manufacturers" => 'manufacturers' ); @@ -790,7 +790,7 @@ class ShippingRule { // The scoping functions need to be handled differently, because they first need to adjust the cart variables to the filtered product list // before evaluating its first argument. So even though parsing the rules handles scoping functions like any other function, their // evaluation is fundamentally different and is special-cased here: - $scoping_functions = array("evaluate_for_categories", "evaluate_for_products", "evaluate_for_vendors", "evaluate_for_manufacturers"); + $scoping_functions = array("evaluate_for_categories", "evaluate_for_products", "evaluate_for_skus", "evaluate_for_vendors", "evaluate_for_manufacturers"); $is_scoping = is_array($expr) && ($expr[0]=="FUNCTION") && (count($expr)>1) && in_array($expr[1], $scoping_functions); if (is_null($expr)) { @@ -808,7 +808,11 @@ class ShippingRule { $op = array_shift($expr); // ignore the "FUNCTION" $func = array_shift($expr); // The scoping function name $expression = array_shift($expr); // The expression to be evaluated - $conditions = $expr; // the remaining $expr list now contains the conditions + // the remaining $expr list now contains the conditions. Evaluate them one by one: + $conditions = array(); + foreach ($expr as $e) { + $conditions[] = $this->evaluateTerm($e, $vals, $products, $cartvals_callback); + } return $this->evaluateScoping ($expression, $func, $conditions, $vals, $products, $cartvals_callback); } elseif (is_array($expr)) { -- GitLab