I keep getting rules logging errors whenever I create a conditional tax rule. The errors are as follows:
(1) Unable to evaluate condition commerce_order_compare_address.
(2) The variable or parameter commerce_order is empty.
I followed the suggested setup here for setting up conditional rules based off of the address. (http://www.drupalcommerce.org/node/454).
When I don't have a session for commerce is puts these errors into the log as soon as I add something to the cart and create the session it stops.
Attached is the comparison rule i was using
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 1299498.initialize_order_in_getter_callbacks.patch | 1.25 KB | rszrama |
| #7 | tax.png | 48.17 KB | erichomanchuk |
| #7 | tax2.png | 56.27 KB | erichomanchuk |
| Screen-shot-2011-10-04-at-3.58.06-PM.jpg | 48.62 KB | erichomanchuk |
Comments
Comment #1
afoster commentedI noticed this one too - subscribed
Comment #2
rszrama commentedDo you get these errors when you update to Entity API 1.0-beta11 and Rules 2.0?
Comment #3
rszrama commentedI'm going to need more information to be able to help here. Can you export the Rule and post it in here?
Comment #4
invisibleink commentedI'm having the same issue, but it only happens when the address comparison is based on Shipping address. It works fine with billing address components.
I hope that helps find the source of the error.
Thanks!
Comment #5
rszrama commentedPlease export the rule as I said above. I can't debug it without seeing the whole thing.
Comment #6
erichomanchuk commentedHere is the export of the rule:
{ "commerce_tax_rate_gst" : {
"LABEL" : "Calculate GST",
"PLUGIN" : "rule",
"REQUIRES" : [ "commerce_order", "commerce_tax" ],
"USES VARIABLES" : { "commerce_line_item" : { "type" : "commerce_line_item", "label" : "Line item" } },
"IF" : [
{ "commerce_order_compare_address" : {
"commerce_order" : [ "commerce-line-item:order" ],
"address_field" : "commerce_customer_billing|commerce_customer_address",
"address_component" : "administrative_area",
"value" : "CO"
}
}
],
"DO" : [
{ "commerce_tax_rate_apply" : {
"commerce_line_item" : [ "commerce-line-item" ],
"tax_rate_name" : "gst"
}
}
]
}
}
Comment #7
erichomanchuk commentedI just tried it again today when I create a new tax and configure the component to apply the tax rate on the address component using the administrative_area (state/province) when a anonymous user, a user with no session, views a page of the site it adds these warnings to the logs.
rules 11/10/2011 - 12:33 Unable to evaluate condition commerce_order_compare... Anonymous (not verified)
rules 11/10/2011 - 12:33 The variable or parameter commerce_order is empty. Anonymous (not verified)
rules 11/10/2011 - 12:33 Unable to evaluate condition commerce_order_compare... Anonymous (not verified)
rules 11/10/2011 - 12:33 The variable or parameter commerce_order is empty. Anonymous (not verified)
When you do add a product to your cart it does go away. Its just that I created all these rules for GST, PST, HST for Canada so I get like 50 of these messages in the log files every time a user with no session looks at a page, so my log files are long. Its not effect my site at all.
Also I noticed today as well when adding a new tax that I didn't get the "configure component" action, it did show up when I added another tax but the new taxes "configure component" action was missing. Attached is a screenshot showing how PST is missing "configure component" action and another screenshot showing how after adding a new tax HST, the "configure component" shows up for PST.
Comment #8
rszrama commentedOooh, I bet I know the problem. I'll do some testing with a cartless anonymous session, too. I'm guessing all my testing of that condition involved users with carts because I knew that's what I was looking to test, but without a cart it is apparently receiving an empty order object.
Comment #9
rszrama commentedAlrighty, finally figured it out. What threw me off in the other reports is that you're only seeing these notices in the recent log messages. I never saw them on screen as error messages, so I assumed there was something about the environment causing the problems. It is as I mused above - newly created line items that did not have an order ID set (such as when a user didn't have a cart order, whether you were authenticated or anonymous) resulted in an empty value being passed to the various hooks for the Order.
It was simple enough to fix; in both the line item and payment transaction getter callbacks for their order_id properties I've added a check to see if order_id is empty before returning it. If it is, we return a new order object instead. Let's see what the test bot has to say about this approach.
Comment #10
rszrama commentedAlrighty, committing this. I'm pretty sure there are related issues in the queue that this resolves, but I'll be darned if I can find any of them. I was just talking with someone about in IRC today, even. It's a mystery. If anyone knows of related issues reporting Rules log spam, please mark them duplicate and link to this issue.
Comment #11
erichomanchuk commentedThank you very much, i will try the patch.
Comment #12
erichomanchuk commentedproblem solved, Thanks Again.
Comment #13
rszrama commentedAwesome, glad to hear it.