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

Forward port of V5.7: Add variables MinQuantity and MaxQuantity

parent 41fd5a2e
Branches
Tags
No related merge requests found
...@@ -210,7 +210,12 @@ class RulesShippingFramework { ...@@ -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 */ /** 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) { 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) { protected function getOrderDimensions ($cart, $products, $method) {
......
...@@ -98,13 +98,21 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework { ...@@ -98,13 +98,21 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework {
* - getOrderDimensions * - getOrderDimensions
*/ */
/** Functions to calculate all the different variables for the given cart and given (sub)set of products in the cart */ /** 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) { protected function getOrderCounts (VirtueMartCart $cart, $products, $method) {
$counts = array('products' => count($products)); $counts = array(
$articles = 0; 'articles' => 0,
'products' => count($products),
'minquantity' => 9999999999,
'maxquantity' => 0,
);
foreach ($products as $product) { 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; return $counts;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment