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

Work on scoping functions. Not yet finished

parent a930dfa9
No related branches found
No related tags found
No related merge requests found
...@@ -1113,7 +1113,31 @@ class ShippingRule { ...@@ -1113,7 +1113,31 @@ class ShippingRule {
} }
} }
function evaluateFunction ($function, $args) { /** Evaluate the given expression $expr only for the products that match the filter given by the scoping
* function and the corresponding conditions */
protected function evaluateScoping($expr, $scoping, $conditionvals, $vals) {
if (count($conditions)<1)
return $this->evaluateTerm($expr, $vals);
$filterkeys = array(
"evaluate_for_categories" => 'categories',
"evaluate_for_products" => 'products',
"evaluate_for_vendors" => 'vendors',
"evaluate_for_manufacturers" => 'manufacturers'
);
$conditions = array();
if (isset($filterkeys[$scoping]))
$conditions[$filterkeys[$scoping]] = $conditionsvals;
// Pass the conditions to the parent plugin class to filter the current list of products:
$products = filterProducts($currentproducts, $conditions);
$vals = $this->plugin->getCartValues ($cart, $products, /* FIXME: method*/ $this->method, $cart_prices);
// FIXME: IMPLEMENT
// TODO
}
protected function evaluateFunction ($function, $args) {
$func = strtolower($function); $func = strtolower($function);
// Check if we have a custom function definition and use that if so. // Check if we have a custom function definition and use that if so.
// This is done first to allow plugins to override even built-in functions! // This is done first to allow plugins to override even built-in functions!
...@@ -1225,6 +1249,13 @@ class ShippingRule { ...@@ -1225,6 +1249,13 @@ class ShippingRule {
} else { } else {
return $this->evaluateVariable($expr, $vals); return $this->evaluateVariable($expr, $vals);
} }
} elseif ($is_scoping) {
$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
return $this->evaluateScoping ($expression, $func, $conditions, $vals);
} elseif (is_array($expr)) { } elseif (is_array($expr)) {
// Operator // Operator
$op = array_shift($expr); $op = array_shift($expr);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment