diff --git a/Makefile b/Makefile index a65019da4ca5c65e5d482084bb7a35a08062b79d..f95406c1b4abc581b3addc4ac8f7d22c2c7214c1 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ BASE=rules_shipping BASE_ADV=rules_shipping_advanced PLUGINTYPE=vmshipment ZIPBASE=opentools_vm -VERSION=5.6 +VERSION=5.7 PLUGINFILES=$(BASE).php $(BASE)_base.php $(BASE).script.php $(BASE).xml index.html PLUGINFILES_ADV=$(BASE_ADV).php $(BASE)_base.php $(BASE_ADV).script.php $(BASE_ADV).xml index.html diff --git a/images/plg_vmshipping_rules_shipping_plugins_icon.png b/images/plg_vmshipping_rules_shipping_plugins_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..7896782784605297bb2f487ae0e3e440af8e1d8f Binary files /dev/null and b/images/plg_vmshipping_rules_shipping_plugins_icon.png differ diff --git a/releases/plg_opentools_vm_rules_shipping_advanced_v5.7.zip b/releases/plg_opentools_vm_rules_shipping_advanced_v5.7.zip new file mode 100644 index 0000000000000000000000000000000000000000..89189fd6632109a40e459580fe82ce19a7cfb8a2 Binary files /dev/null and b/releases/plg_opentools_vm_rules_shipping_advanced_v5.7.zip differ diff --git a/releases/plg_opentools_vm_rules_shipping_v5.7.zip b/releases/plg_opentools_vm_rules_shipping_v5.7.zip new file mode 100644 index 0000000000000000000000000000000000000000..bea3b197fab3cf0c7521bd9a0e374a62bd3e614e Binary files /dev/null and b/releases/plg_opentools_vm_rules_shipping_v5.7.zip differ diff --git a/rules_shipping.xml b/rules_shipping.xml index 2f691c73da0d3d687b443e74aab63bec70a23d12..582b0ff29cbd887ebf7973e9b2e6fe6e84f651f9 100644 --- a/rules_shipping.xml +++ b/rules_shipping.xml @@ -6,7 +6,7 @@ <authorUrl>http://www.open-tools.net</authorUrl> <copyright>Copyright (C) 2013-2014, Reinhold Kainhofer</copyright> <license>GPL v3+</license> - <version>5.6</version> + <version>5.7</version> <description>VMSHIPMENT_RULES_DESC</description> <files> <filename plugin="rules_shipping">rules_shipping.php</filename> diff --git a/rules_shipping_base.php b/rules_shipping_base.php index f250d03151baf60c0e9434115887970df857892e..f11a23d1b86a4ad0ef61d0d0e5cdd1c036ddda61 100644 --- a/rules_shipping_base.php +++ b/rules_shipping_base.php @@ -167,7 +167,7 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { } // We need to call getCosts, because in J3 $method->rule_name and $method->cost as set in getCosts is no longer preserved. // Instead, we simply call getCosts again, which as a side-effect sets all those members of $method. - $costs = $this->getCosts($cart,$method,$cart->cartPrices); + $costs = $this->getCosts($cart,$method,isset($cart->cartPrices)?($cart->cartPrices):array()); $values['virtuemart_order_id'] = $order['details']['BT']->virtuemart_order_id; $values['order_number'] = $order['details']['BT']->order_number; $values['virtuemart_shipmentmethod_id'] = $order['details']['BT']->virtuemart_shipmentmethod_id; @@ -175,8 +175,9 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { $values['rule_name'] = $method->rule_name; $weights = $this->getOrderWeights ($cart, $cart->products, $method->weight_unit); $values['order_weight'] = $weights['weight']; - $values['order_articles'] = $this->getOrderArticles ($cart, $cart->products); - $values['order_products'] = $this->getOrderProducts ($cart, $cart->products); + $counts = $this->getOrderCounts ($cart, $cart->products); + $values['order_articles'] = $counts['articles']; + $values['order_products'] = $counts['products']; $values['shipment_weight_unit'] = $method->weight_unit; $values['shipment_cost'] = $method->cost; $values['tax_id'] = $method->tax_id; @@ -593,16 +594,22 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { } /** Functions to calculate all the different variables for the given cart and given (sub)set of products in the cart */ - protected function getOrderArticles (VirtueMartCart $cart, $products) { - $articles = 0; + protected function getOrderCounts (VirtueMartCart $cart, $products) { + $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); } - return $articles; - } - - protected function getOrderProducts (VirtueMartCart $cart, $products) { - return count($products); + $counts['quantity'] = $counts['articles']; + + return $counts; } protected function getOrderDimensions (VirtueMartCart $cart, $products, $length_dimension) { @@ -808,10 +815,7 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { public function getCartValues (VirtueMartCart $cart, $products, $method, $cart_prices) { $address = (($cart->ST == 0 || $cart->STsameAsBT == 1) ? $cart->BT : $cart->ST); $cartvals = array_merge ( - array( - 'articles'=>$this->getOrderArticles($cart, $products), - 'products'=>$this->getOrderProducts($cart, $products), - ), + $this->getOrderCounts ($cart, $products), // Add the prices, optionally calculated from the products subset of the cart $this->getOrderPrices ($cart, $products, $cart_prices), // Add 'skus', 'categories', 'vendors' variables: