Login
Register

VirtueMart

WooCommerce

Others

Docs

Support

Blog

About

Shipping by Rules for VirtueMart

IMPORTANT ANNOUNCEMENT: Plugin development ceased, all plugins made available freely (GPL)

With great sadness we have to announce that we are ceasing development of all our VirtueMart, WooCommerce and Joomla plugins. Effective immediately, all our plugins -- even those that were paid downloads -- are made available for free from our homepage (GPL license still applies), but we cannot and will not provide any support anymore.

It has been a great pleasure to be part of the thriving development communities of VirtueMart as well as WooCommerce. However, during the last year it became painstakingly clear that in addition to a full-time job, a young family and several other time-consuming hobbies at professional level (like being a professional singer) the plugin development and the support that it requires is not sustainable and is taking its toll. It has been an honor, but it is now time to say good bye!

×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Why this rule doesn't match? 16 Sep 2013 13:10 #1

  • rnunes
  • rnunes's Avatar Topic Author
Hi, I'm using the advanced plugin and I'm having some trouble with matches. I have TNT Express and, apparently, the plugin is trying to match the rules twice succeeding with one rule at the first attempt and failing on the second, which makes an overall "not match" (see the log below).

I've added some debug messages in rules_shipping_base.php:

protected function checkConditions ($cart, $method, $cart_prices) {
if (!isset($method->rules)) $this->parseMethodRules($method);

$cartvals = $this->getCartValues ($cart, $method, $cart_prices);
foreach ($method->rules as $r) {
if ($r->matches($cartvals)) {

$method->matched_rule = $r;
$method->rule_name = $r->getRuleName($cartvals);

// If NoShipping is set, this method should NOT offer any shipping at all, so return FALSE, otherwise TRUE
if ($r->isNoShipping()) {
vmdebug('checkConditions '.$method->shipment_name.' indicates NoShipping for rule "'.$method->rule_name.'" ('.$r->rulestring.').');
return FALSE;
} else {
vmdebug('Match: '.$method->rule_name);
return TRUE;
}
} else {
vmdebug('Doesnt match: '.$r->getRuleName($cartvals));
}
}
vmdebug('checkConditions '.$method->shipment_name.' does not fit');
return FALSE;
}

This is the debug messages and, as you can see, rule TNT Express Portugal Zone 1 have a match in first iteration and fails in the second. What is going on? Is that related to having more then one rule with the same name?

vmdebug My selected language by JFactory::getLanguage()->getTag() en-GB
vmdebug self::$_jpConfig->lang en_gb
vmdebug vmTime: loadConfig db no: 0.018415927886963
vmdebug Start used Ram 7M
vmdebug getOrderWeight Var1:

0.1000

vmdebug shipmentmethod Fedex = TRUE for variable weight = 0.1 Reason: no boundary conditions set
vmdebug shipmentmethod Fedex = TRUE for variable products quantity = 1 Reason: no boundary conditions set
vmdebug shipmentmethod Fedex = TRUE for variable order amount = 123 Reason: no boundary conditions set
vmdebug shipmentmethod Fedex = TRUE for variable zip = 2600-041 Reason: no boundary conditions set
vmdebug shipmentmethod Fedex = TRUE for variable virtuemart_country_id = , Reason: Country in rule or none set
vmdebug Doesnt match: TNT Express Spain
vmdebug Doesnt match: TNT Express Spain
vmdebug Doesnt match: TNT Express Spain
vmdebug Doesnt match: TNT Express Zone 1
vmdebug Doesnt match: TNT Express Zone 1
vmdebug Doesnt match: TNT Express Zone 1
vmdebug Doesnt match: TNT Express Zone 2
vmdebug Doesnt match: TNT Express Zone 2
vmdebug Doesnt match: TNT Express Zone 2
vmdebug Doesnt match: TNT Express Zone 3
vmdebug Doesnt match: TNT Express Zone 3
vmdebug Doesnt match: TNT Express Zone 3
vmdebug Doesnt match: TNT Express Zone 6
vmdebug Doesnt match: TNT Express Zone 6
vmdebug Doesnt match: TNT Express Zone 6
vmdebug Doesnt match: TNT Express Madeira
vmdebug Doesnt match: TNT Express Madeira
vmdebug Doesnt match: TNT Express Açores
vmdebug Doesnt match: TNT Express Açores
vmdebug Doesnt match: TNT Express Portugal Zone 2
vmdebug Doesnt match: TNT Express Portugal Zone 2
vmdebug Match: TNT Express Portugal Zone 1
vmdebug CheckAutomaticSelectedShipment Var1:

Array
(
[0] => 8
[1] => 7
)

vmdebug shipmentmethod Fedex = TRUE for variable weight = 0.1 Reason: no boundary conditions set
vmdebug shipmentmethod Fedex = TRUE for variable products quantity = 1 Reason: no boundary conditions set
vmdebug shipmentmethod Fedex = TRUE for variable order amount = 123 Reason: no boundary conditions set
vmdebug shipmentmethod Fedex = TRUE for variable zip = 2600-041 Reason: no boundary conditions set
vmdebug shipmentmethod Fedex = TRUE for variable virtuemart_country_id = , Reason: Country in rule or none set
vmdebug shipmentmethod Fedex = TRUE for variable weight = 0.1 Reason: no boundary conditions set
vmdebug shipmentmethod Fedex = TRUE for variable products quantity = 1 Reason: no boundary conditions set
vmdebug shipmentmethod Fedex = TRUE for variable order amount = 123 Reason: no boundary conditions set
vmdebug shipmentmethod Fedex = TRUE for variable zip = 2600-041 Reason: no boundary conditions set
vmdebug shipmentmethod Fedex = TRUE for variable virtuemart_country_id = , Reason: Country in rule or none set
vmdebug Doesnt match: TNT Express Spain
vmdebug Doesnt match: TNT Express Spain
vmdebug Doesnt match: TNT Express Spain
vmdebug Doesnt match: TNT Express Zone 1
vmdebug Doesnt match: TNT Express Zone 1
vmdebug Doesnt match: TNT Express Zone 1
vmdebug Doesnt match: TNT Express Zone 2
vmdebug Doesnt match: TNT Express Zone 2
vmdebug Doesnt match: TNT Express Zone 2
vmdebug Doesnt match: TNT Express Zone 3
vmdebug Doesnt match: TNT Express Zone 3
vmdebug Doesnt match: TNT Express Zone 3
vmdebug Doesnt match: TNT Express Zone 6
vmdebug Doesnt match: TNT Express Zone 6
vmdebug Doesnt match: TNT Express Zone 6
vmdebug Doesnt match: TNT Express Madeira
vmdebug Doesnt match: TNT Express Madeira
vmdebug Doesnt match: TNT Express Açores
vmdebug Doesnt match: TNT Express Açores
vmdebug Doesnt match: TNT Express Portugal Zone 2
vmdebug Doesnt match: TNT Express Portugal Zone 2
vmdebug Doesnt match: TNT Express Portugal Zone 1
vmdebug Doesnt match: TNT Express Portugal Zone 1
vmdebug checkConditions TNT Express does not fit
vmdebug vmTime: VirtuemartControllerCart Finished task edit_shipment: 0.58722519874573
vmdebug End used Ram 19.25M
vmdebug Peak memory peak 19.5M

Why this rule doesn't match? 17 Sep 2013 01:57 #2

Could you please also post your rules. Debugging is quite hard without the actual rules that you are using...
Thanks,
Reinhold

Why this rule doesn't match? 17 Sep 2013 10:11 #3

  • rnunes
  • rnunes's Avatar Topic Author
I have several rules, but for Portugal (the test that I'm making), I have the following rules:
  1. Name=TNT Express Portugal Zone 2; State=="Portugal Continental"; ZIP4>=5000 AND ZIP4<=5999 OR ZIP4==6050 OR ZIP4>=7000 AND ZIP4<=8999; Weight <= 5; Shipping = 5.5
  2. Name=TNT Express Portugal Zone 2; State=="Portugal Continental"; ZIP4>=5000 AND ZIP4<=5999 OR ZIP4==6050 OR ZIP4>=7000 AND ZIP4<=8999; Weight > 5; Shipping = 5.5 + 0.25*ceil(weight-5.0)
  3. Name=TNT Express Portugal Zone 1; State=="Portugal Continental"; Weight <= 5; Shipping=5.0
  4. Name=TNT Express Portugal Zone 1; State=="Portugal Continental"; Weight > 5; Shipping = 5.0 + 0.25*ceil(weight-5.0)

So, basically, TNT Express have 2 different zones in Portugal and have a fixed price for under 5kg orders and a fixed price for every extra kg.

In the test I'm making, I have a user from Portugal, postal code 2600 (Zone 1) wich makes an order that weigh 100g (under 5kg).

Like I said before, according to the debug messages there's a rule match once but in the second iteration it fails (I don't even understand why there's two iterations, it's that expected?).

I've removed comments in the file mentioned above in the matches function to see how the rules are being evaluated:
JFactory::getApplication()->enqueueMessage("Evaluating term <pre>".print_r($c,1)."</pre> returns $ret", 'error');

And the printed messages are here . Briefly explanation: first rules (with State == Madeira/Açores) are not applicable here, only the TNT Express Portugal Zone 1 rule and, as you can see the last two comparisons are true (State == Portugal Continental and Weight <= 5kg) but they don't assume shipping as 5.0 (as they should, because that is rule number 3).

Why this rule doesn't match? 19 Sep 2013 20:07 #4

  • rnunes
  • rnunes's Avatar Topic Author
Any update on this?

I've just found this message all over my php error logs. I'm using PHP 5.4.19.
[19-Sep-2013 11:51:11] PHP Notice:  Undefined index: FUNCTION( in .../plugins/vmshipment/rules_shipping_advanced/rules_shipping_advanced.php on line 290

EDIT:

If I enter in the select shipment link (/index.php/shop/cart/edit_shipment) with an empty cart this rule will have a match and appear in the Shipping selection.

Why this rule doesn't match? 20 Sep 2013 23:31 #5

Can you please try the latest version 3.3, which I just released.
There were some bugs, which are fixed with that release. In particular:
-) Arithmetic operations inside function calls were incorrectly parsed (causing the PHP log entries, and also causing the evaluation of that rule to fail)
-) country/state checks somehow did not properly work in all cases when a country had states.

Why this rule doesn't match? 23 Sep 2013 15:52 #6

  • rnunes
  • rnunes's Avatar Topic Author
Problem solved :) Thanks for the update

[SOLVED] Why this rule doesn't match? 24 Sep 2013 21:44 #7

Problem solved.
  • Page:
  • 1