From 2eefc77462207c5f5f993f545c88994519ef6c39 Mon Sep 17 00:00:00 2001
From: Reinhold Kainhofer <reinhold@kainhofer.com>
Date: Mon, 13 Jul 2015 23:31:30 +0300
Subject: [PATCH] Some more refactoring to the library

---
 library/rules_shipping_framework.php | 7 ++++++-
 rules_shipping_framework_joomla.php  | 4 ++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/library/rules_shipping_framework.php b/library/rules_shipping_framework.php
index 9a33f4d..ce7118b 100644
--- a/library/rules_shipping_framework.php
+++ b/library/rules_shipping_framework.php
@@ -263,6 +263,10 @@ class RulesShippingFramework {
 
 		return $cartvals;
 	}
+	
+	protected function getCartProducts($cart, $method) {
+		return array();
+	}
 
 	/** This function evaluates all rules, one after the other until it finds a matching rule that
 	 *  defines shipping costs (or uses NoShipping). If a modifier or definition is encountered,
@@ -274,7 +278,7 @@ class RulesShippingFramework {
 			return $this->match[$id];
 		} else {
 			// Evaluate all rules and find the matching ones (including modifiers and definitions!)
-			$cartvals = $this->getCartValues ($cart, $cart->products, $method);
+			$cartvals = $this->getCartValues ($cart, $this->getCartProducts($cart, $method), $method);
 			$result = array(
 				"rule" => Null,
 				"rule_name" => "",
@@ -670,6 +674,7 @@ class ShippingRule {
 		$filterkeys = array( 
 			"evaluate_for_categories" =>    'categories',
 			"evaluate_for_products" =>      'products',
+			"evaluate_for_skus" =>          'products',
 			"evaluate_for_vendors" =>       'vendors',
 			"evaluate_for_manufacturers" => 'manufacturers'
 		);
diff --git a/rules_shipping_framework_joomla.php b/rules_shipping_framework_joomla.php
index c402dc1..907cae9 100644
--- a/rules_shipping_framework_joomla.php
+++ b/rules_shipping_framework_joomla.php
@@ -68,6 +68,10 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework {
 		$method->includes_tax = $r->includes_tax;
 	}
 	
+	protected function getCartProducts($cart, $method) {
+		return $cart->products;
+	}
+	
 	protected function getMethodId($method) {
 		return $method->virtuemart_shipmentmethod_id;
 	}
-- 
GitLab