OK, as of a day or two ago, one of my Commerce sites has started to apply no VAT to orders.
Symptoms:
- VAT is applied correctly on Product display pages, and on the Basket page.
- VAT is not applied at all on the Checkout Page, or after that in the checkout process.
- If I add an empty coupon code to the order, the page refreshes and VAT is added correctly!
Stepping through the code with a debugger I just get hopelessly lost. I can't see the wood for the trees, there are so many function and method calls! I've learnt that you have to clear the cache too, otherwise the price field is simply loaded from cache, and not calculated from the base price plus taxes.
There aren't any errors reported in Drupal watchdog nor Apache logs.
Looking at the database, when I view the order's Basket, the line item commerce_unit_price_amount in the field_data_commerce_unit_price table includes VAT, and the commerce_unit_price_data includes all the VAT details.
But just going to the Checkout page causes the line item price to lose VAT, both in the price_amount and in the price_data.
Then refreshing the order by adding an empty discount coupon code adds in VAT to the display and to the line item data in the database.
Comment | File | Size | Author |
---|---|---|---|
#10 | cart_missing_handler.png | 60.15 KB | Channel Islander |
#8 | multiple_rule_evauations.png | 86.63 KB | Channel Islander |
#2 | 2015-01-15 14_54_15-Checkout.png | 19.58 KB | fonant |
#2 | 2015-01-15 14_54_04-Checkout.png | 17.01 KB | fonant |
Comments
Comment #1
adwuk CreditAttribution: adwuk commentedHave you recently upgraded Rules? There is a problem with product pricing rules that breaks with v2.8 Rules, so a few people have downgraded to v2.7. Might be related.
Comment #2
fonant CreditAttribution: fonant commentedI've added a "price formatted with components" field to the cart contents View, to see what's going on.
Here's the checkout on first page load:
Note how VAT is missing from the line item (although it included VAT in the Basket) but is being added OK for the shipping charge.
Here's the same page just after I've added an empty coupon code to refresh the order:
Comment #3
fonant CreditAttribution: fonant commentedFor reference, here's the bug report for Rules: #2403851: Drupal Commerce is broken with Rules 7.x-2.8
Comment #4
fonant CreditAttribution: fonant commentedUpdated issue title.
Comment #5
rszrama CreditAttribution: rszrama commentedBummer. Well, this isn't a bug in Commerce itself - Rules made a change and the unintended consequence is that it breaks common functionality in Drupal Commerce. Not the first time. : P
Let's leave this open so people can be directed to the patch and see how the Rules maintainers respond.
#2403851-9: Drupal Commerce is broken with Rules 7.x-2.8
Comment #6
Channel Islander CreditAttribution: Channel Islander commentedI am having difficulties fixing this problem.
My issue does not involve pricing rules, but does appear to be caused by the bug in Rules 1.28 which causes Rules to get invoked too soon. In my case, Rules is reacting on the event "Select available payment methods for an order" right at the beginning, before checkout, when first adding a product to the cart. (The same error occurs all the way through checkout with basically every event being reacted to, no matter where you are.)
So I followed the advice and downgraded Rules to 1.27. But the problem hasn't been fixed!
What I did:
But still the "Select available payment methods for an order" event is reacted to when first adding a product to the cart, and again on Checkout:Review.
When _should_ the "Select available payment methods for an order" event get reacted to?
Comment #7
fonant CreditAttribution: fonant commented"Select available payment methods for an order" is fired when you reach the checkout page containing the payment method selector. Typically this is after the Shipping page, and just before the Review page.
Comment #8
Channel Islander CreditAttribution: Channel Islander commented@fonant, that's what I thought, but haven't found the canonical list. IMO it could have a clearer name. It's not clear whether the event is when the selection options are loaded or when the user selects one of them.
If it is the former, as I assume it is, a better name would be "Display available payment options for an order."
In any case there's no way "Select available payment methods for an order" should be reacted to upon adding a product to the cart, amiright?
Comment #9
fonant CreditAttribution: fonant commentedThe event is triggered when the payment methods that are available for an order are gathered for display. So the "Select" is meant in terms of Commerce selecting, not the customer. I do see the confusion if you think of "Select" in terms of the customer's actions.
"Gather available payment methods for an order" would be most logical, although "Display" would work too since the display of the options is what triggers the rule that gathers the options.
The "Select available payment methods for an order" shouldn't fire for the Cart page, no, unless you've added the payment options widget to the Cart page somehow.
Looks like the "Calculating the sell price of a product" is firing too often for you as well, there's only one product in the cart that would need its price to be calculated.
Comment #10
Channel Islander CreditAttribution: Channel Islander commented@fonant, Thank you for your reply. It's amazing how a throw-away comment by someone who knows, can be just the clue one needs. You said
. . .
I was so hopeful because, yes, I did find a stray widget in the Cart on my test server, a leftover from a failed experiment with Product Attributes :
However, I removed it, cleared the cache and the error remains the same. Argh.
Additionally, the same error occurs on a different server that never had Product Attributes or Product Options modules installed. The thing the two servers have in common, that a third, which is not having the error, does not, is to have had Rules 1.28 installed (and then downgraded).
Can you help me track this down?
How can I make sure my Shopping Cart view is the default?
Is there any way to further debug the Rules calls, and identify what is calling them, or why they are getting called?
Comment #11
fonant CreditAttribution: fonant commented@Channel Islander - product attributes won't have any effect. The only thing that I can think of that would cause the "Select available payment methods for an order" event to occur is if you had the "Payment" checkout pane on the Cart page, which is unlikely. It's normally on the "Review" page.
Sorry, I don't have time to help you track this down.
You could make sure you have all the default settings by disabling and uninstalling all your Commerce modules, but that would also delete all Commerce data as well as settings, so no good if the site has already been used.
Comment #12
Channel Islander CreditAttribution: Channel Islander commented@fonant, I disabled all my Rules and added them back one by one.
Solved!
I discovered the cause was that I had both Paypal Express Checkout and Paypal WPP enabled.
This causes the Paypal checkout button to not be displayed until the normal payment method selection, but the code causes the Event "Select available payment methods for an order" to be evaluated at Paypal EC's normal place in checkout, which is to say, at the beginning, in the cart. Because the button wasn't displaying, I didn't suspect it.
Seems like it should be documented somewhere. I'll post in the Paypal EC and WPP issue threads. Thanks for your help.
Comment #13
sierkje CreditAttribution: sierkje commentedComment #14
zterry95 CreditAttribution: zterry95 commentedFixed by upgrade rules to 7.x-2.x-dev.
a lot time spend on dig the code and explain to client:(
Comment #15
rszrama CreditAttribution: rszrama commented@zterry95 Understood, it's a frustrating part of depending on other contribs. We do try to communicate this sort of information in the header of our release notes, though, so I'd start there in the future.
Comment #16
roball CreditAttribution: roball commentedRules 7.x-2.9 has just been released: "This release fixes an incompatibility of Rules 2.8 with Drupal commerce".
Can anybody confirm that it is fine to update from Rules 2.7 to 2.9, and Commerce continues to work fine?
Comment #17
mmtt CreditAttribution: mmtt commentedI'v done a fresh install of commerce, commerce_custom_product and rules-7.x-2.7. As josh i created somthink like "Customizable Product with Drupal Commerce: Pizza Store". Even i created the necessary rules to add the custom fees to the amount. But the price will not change in the cart.
Is there maybe something else to know beside the downgrading rules to get it to work?
Comment #18
bojanz CreditAttribution: bojanz commentedRules 2.9 was released, fixing the regression.
Comment #19
roball CreditAttribution: roball commentedI just confirm that Rules 7.x-2.9 is working perfectly fine with Drupal commerce.
Comment #20
ShaneOnABike CreditAttribution: ShaneOnABike commentedI can also confirm that what a HUGE relief lordy!