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

Implement country/state variables

parent f1a36c32
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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>
......
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment