Commit 6d4c2331 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

V6.1.6: Add user variables, merge improvements from library(WC dev)

New variables:
- Shoppergroups
- groups
- UserID
- UserName
- isVendor
- isGuest
- CustomerNumber

Fixes issue #16
parent d63dd39e
......@@ -2,7 +2,7 @@ BASE=rules_shipping
BASE_ADV=rules_shipping_advanced
PLUGINTYPE=vmshipment
ZIPBASE=opentools_vm
VERSION=6.1.5
VERSION=6.1.6
PLUGINFILES=$(BASE).php $(BASE)_base.php $(BASE)_framework_joomla.php $(BASE).script.php $(BASE).xml index.html
PLUGINFILES_ADV=$(BASE_ADV).php $(BASE)_base.php $(BASE)_framework_joomla.php $(BASE_ADV).script.php $(BASE_ADV).xml index.html
......
......@@ -275,6 +275,10 @@ class RulesShippingFramework {
return array();
}
protected function getOrderUser ($cart, $method) {
return array();
}
protected function getOrderAddress ($cart, $method) {
return array();
}
......@@ -354,6 +358,8 @@ class RulesShippingFramework {
$this->getOrderListProperties ($cart, $products, $method),
// Add country / state variables:
$this->getOrderAddress ($cart, $method),
// Add Customer information:
$this->getOrderUser ($cart, $method),
// Add Total/Min/Max weight and dimension variables:
$this->getOrderWeights ($cart, $products, $method),
$this->getOrderDimensions ($cart, $products, $method),
......@@ -425,7 +431,7 @@ class RulesShippingFramework {
}
}
// None of the rules matched, so return NULL, but keep the evaluated results;
$this->match[$id] = $result;
$this->match[$id] = NULL;
return NULL;
}
......@@ -453,7 +459,7 @@ class RulesShippingFramework {
$this->parseMethodRules($method);
// TODO: This needs to be redone sooner or later!
$match = $this->evaluateMethodRules ($cart, $method);
if ($match && !is_null ($match['rule'])) {
if ($match && isset($match['rule']) && !is_null ($match['rule'])) {
$this->setMethodCosts($method, $match, null);
// If NoShipping is set, this method should NOT offer any shipping at all, so return FALSE, otherwise TRUE
// If the rule has a name, print it as warning (otherwise don't print anything)
......@@ -484,7 +490,7 @@ class RulesShippingFramework {
if (!isset($this->rules[$id]))
$this->parseMethodRules($method);
$match = $this->evaluateMethodRules ($cart, $method);
if ($match) {
if ($match && isset($match['rule']) && !is_null ($match['rule'])) {
if ($this->handleNoShipping($match, $method)) {
return $results;
}
......
......@@ -6,7 +6,7 @@
<authorUrl>http://www.open-tools.net</authorUrl>
<copyright>Copyright (C) 2013-2014, Reinhold Kainhofer</copyright>
<license>GPL v3+</license>
<version>6.1.5</version>
<version>6.1.6</version>
<description>OTSHIPMENT_RULES_DESC</description>
<files>
<filename plugin="rules_shipping">rules_shipping.php</filename>
......
......@@ -6,7 +6,7 @@
<authorUrl>http://www.open-tools.net</authorUrl>
<copyright>Copyright (C) 2013-2014, Reinhold Kainhofer</copyright>
<license>GPL v3+</license>
<version>6.1.5</version>
<version>6.1.6</version>
<description>OTSHIPMENT_RULES_ADV_DESC</description>
<files>
<filename plugin="rules_shipping_advanced">rules_shipping_advanced.php</filename>
......
......@@ -211,6 +211,21 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework {
);
}
protected function getOrderUser ($cart, $method) {
$user = $cart->user;
$uinfo = array(
'shoppergroups' => $user->shopper_groups,
'groups' => $user->JUser->groups,
'userid' => $user->virtuemart_user_id,
'username' => $user->JUser->name,
'isguest' => $user->JUser->guest,
'isvendor' => $user->user_is_vendor,
'customernumber' => $user->customer_number,
);
return $uinfo;
}
protected function getOrderAddress ($cart, $method) {
$address = (($cart->ST == 0 || $cart->STsameAsBT == 1) ? $cart->BT : $cart->ST);
$zip = isset($address['zip'])?trim($address['zip']):'';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment