diff --git a/Makefile b/Makefile index 179747689e44a9604828a490de2f3822fc27c00f..ca3d1492d6257f9215f5b721df40dc7dc3b697c0 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ BASE=rules_shipping BASE_ADV=rules_shipping_advanced PLUGINTYPE=vmshipment ZIPBASE=opentools_vm2 -VERSION=3.0.2 +VERSION=3.1 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/rules_shipping.xml b/rules_shipping.xml index 0ffe6073bd5c1d7fe4207a1bcb02c60c8459be62..ef943d57c93b8fb22bb458e2ffc14cea42985c71 100644 --- a/rules_shipping.xml +++ b/rules_shipping.xml @@ -6,7 +6,7 @@ <authorUrl>http://www.open-tools.net</authorUrl> <copyright>Copyright (C) 2013, Reinhold Kainhofer</copyright> <license>GPL v3+</license> - <version>3.0.2</version> + <version>3.1</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 73d4c5c9686d750040f81f0ba04492472c50658c..e84e2f12ab35c7b0443002960e419a0976e658b0 100644 --- a/rules_shipping_base.php +++ b/rules_shipping_base.php @@ -415,6 +415,33 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { return $dimensions; } + function getOrderCountryState (VirtueMartCart $cart, $address) { + $data = array (); + + $countriesModel = VmModel::getModel('country'); + if (isset($address['virtuemart_country_id'])) { + $countriesModel->setId($address['virtuemart_country_id']); + $country = $countriesModel->getData(); + $data['countryid'] = $country->virtuemart_country_id; + $data['country'] = $country->country_name; + $data['country2'] = $country->country_2_code; + $data['country3'] = $country->country_3_code; + } + + $statesModel = VmModel::getModel('state'); + if (isset($address['virtuemart_country_id'])) { + $statesModel->setId($address['virtuemart_state_id']); + $state = $statesModel->getData(); + $data['stateid'] = $state->virtuemart_state_id; + $data['state'] = $state->state_name; + $data['state2'] = $state->state_2_code; + $data['state3'] = $state->state_3_code; + } + + return $data; + + } + /** Allow child classes to add additional variables for the rules */ protected function addCustomCartValues (VirtueMartCart $cart, $cart_prices, &$values) { @@ -444,15 +471,15 @@ class plgVmShipmentRules_Shipping_Base extends vmPSPlugin { 'discountamount'=>$cart_prices['discountAmount'], 'pricewithouttax'=>$cart_prices['priceWithoutTax'], // 'discountbeforetaxbill'=>$cart_prices['discountBeforeTaxBill'], - - 'country'=>$address['virtuemart_country_id'], ); - + + $cartvals = array_merge ($cartvals, $this->getOrderCountryState ($cart, $address)); $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 $this->addCustomCartValues($cart, $cart_prices, $cartvals); // JFactory::getApplication()->enqueueMessage("<pre>cart prices: ".print_r($cart_prices,1)."</pre>", 'error'); +// JFactory::getApplication()->enqueueMessage("<pre>cart: ".print_r($cart,1)."</pre>", 'error'); return $cartvals; }