diff --git a/library/rules_shipping_framework.php b/library/rules_shipping_framework.php index 42ad51ce6a514019959460f968a3e32251c3d756..0107373174ba7ae363687b017752a3cdea3e4825 100644 --- a/library/rules_shipping_framework.php +++ b/library/rules_shipping_framework.php @@ -210,7 +210,12 @@ class RulesShippingFramework { */ /** Functions to calculate all the different variables for the given cart and given (sub)set of products in the cart */ protected function getOrderCounts ($cart, $products, $method) { - return array('articles' => 0, 'products' => count($products)); + return array( + 'articles' => 0, + 'products' => count($products), + 'minquantity' => 9999999999, + 'maxquantity' => 0, + ); } protected function getOrderDimensions ($cart, $products, $method) { diff --git a/rules_shipping_framework_joomla.php b/rules_shipping_framework_joomla.php index d812deedfd5a17d93e9d25c4b6e379e795126699..0c7f75c6a8d0837cdcfe7fa11fda4a48af49b1d1 100644 --- a/rules_shipping_framework_joomla.php +++ b/rules_shipping_framework_joomla.php @@ -98,13 +98,21 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework { * - getOrderDimensions */ /** Functions to calculate all the different variables for the given cart and given (sub)set of products in the cart */ - protected function getOrderCounts ($cart, $products, $method) { - $counts = array('products' => count($products)); - $articles = 0; + protected function getOrderCounts (VirtueMartCart $cart, $products, $method) { + $counts = array( + 'articles' => 0, + 'products' => count($products), + 'minquantity' => 9999999999, + 'maxquantity' => 0, + ); + foreach ($products as $product) { - $articles += $product->quantity; + $counts['articles'] += $product->quantity; + $counts['maxquantity'] = max ($counts['maxquantity'], $product->quantity); + $counts['minquantity'] = min ($counts['minquantity'], $product->quantity); } - $counts['articles'] = $articles; + $counts['quantity'] = $counts['articles']; + return $counts; }