From 579577b3df79ba12c3548a708a67dbf6ed79a438 Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer <reinhold@kainhofer.com> Date: Fri, 20 Sep 2013 22:33:52 +0200 Subject: [PATCH] Add categories, vendors and manufacturers variables --- rules_shipping_base.php | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/rules_shipping_base.php b/rules_shipping_base.php index 4161138..5a30b5c 100644 --- a/rules_shipping_base.php +++ b/rules_shipping_base.php @@ -415,12 +415,24 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { return $dimensions; } - function getOrderSKUs (VirtueMartCart $cart) { + function getOrderListProperties (VirtueMartCart $cart) { + $categories = array(); + $vendors = array(); $skus = array(); + $manufacturers = array(); foreach ($cart->products as $product) { $skus[] = $product->product_sku; - } - return $skus; + $categories = array_merge ($categories, $product->categories); + $vendors[] = $product->virtuemart_vendor_id; + $manufacturers = array_merge ($manufacturers, $product->virtuemart_manufacturer_id); + } + $categories = array_unique($categories); + $vendors = array_unique($vendors); + return array ('skus'=>$skus, + 'categories'=>$categories, + 'vendors'=>$vendors, + 'manufacturers'=>$manufacturers, + ); } function getOrderCountryState (VirtueMartCart $cart, $address) { @@ -485,14 +497,13 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { 'salespricewithdiscount'=>$cart_prices['salesPriceWithDiscount'], 'discountamount'=>$cart_prices['discountAmount'], 'pricewithouttax'=>$cart_prices['priceWithoutTax'], - - 'skus'=>$this->getOrderSKUs($cart), - // TODO: Add 'categories' variable - // TODO: Add 'vendors'variable -// 'discountbeforetaxbill'=>$cart_prices['discountBeforeTaxBill'], ); + // Add 'skus', 'categories', 'vendors' variables: + $cartvals = array_merge ($cartvals, $this->getOrderListProperties ($cart)); + // Add country / state variables: $cartvals = array_merge ($cartvals, $this->getOrderCountryState ($cart, $address)); + // Add Total/Min/Max weight and dimension variables: $cartvals = array_merge ($cartvals, $this->getOrderWeights ($cart, $method->weight_unit)); $cartvals = array_merge ($cartvals, $this->getOrderDimensions ($cart, $method->length_unit)); // Let child classes update the $cartvals array, or add new variables -- GitLab