Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Product price calculation event is only being fired for orders in a shopping cart statuses (which include Checkout statuses).
As it should be possible to have a cartless, and checkout system, taxes need to be calculated so they can be viewed in full on the View Order page without moving into the cart and checkout declared stauses.
Comments
Comment #1
essbee CreditAttribution: essbee commentedFor anyone interested right now the work around for this is to flick every order into the Checkout: Checkout status. This causes taxes to be calculated for the order.
Comment #2
Damien Tournoud CreditAttribution: Damien Tournoud commentedThe "cart" status means "an order that is not final yet". Even if you implement a cart-less system, you should still put your order in cart status as long as it is not final. You can alter set the 'cart' flag to any status using
hook_commerce_order_status_info()
andhook_commerce_order_status_info_alter()
.Comment #3
essbee CreditAttribution: essbee commentedHi Damien,
The issue here is that orders created through admin don't receive tax application because the calculate price routine is not fired. I can create a perfectly functional system without installing cart or checkout modules but taxes are not calculated. So when the order is viewed, there are no taxes present.
An example use case for this would be an invoicing based system.
Comment #4
essbee CreditAttribution: essbee commentedHmmm ok this issue is actually a bit wider than just the cart part of it.
When editing any order, taxes should be recalculated upon any changes to line items. This is not currently the case for all order statuses.
So as it stands right now it is possible to create a scenario where taxes are not calculated at all, or a scenario where taxes have been calculated, but then items on the order changed but taxes not recalculated to demonstrate.
Is it possible to just have the tax calculation routine firing on all line item changes/additions/deletions?
Comment #5
essbee CreditAttribution: essbee commentedHave renamed this as this is more than just a tax issue.
Not sure whether this should be a separate issue, but noticed the "Unit Price" field on the admin order edit screen is an editable field for non-Price Calculation triggering order statuses, but is disabled for statuses that trigger price calculation.
Price calculating statuses: [Shopping cart: Shopping cart], [Checkout: Checkout] & [Checkout: Review]
This means that an order in [Checkout: Complete] status can have its price updated and the order not total correctly. Given that when the Calculate Sell price routine runs it overrides the price held in Unit Price regardless of whether it has been modified admin, it raises the question as to when one would actually need the field editable.
Comment #6
rszrama CreditAttribution: rszrama commentedThe fact that sell price calculation isn't happening for non-cart statuses is intentional. You wouldn't want your completed orders suddenly changing product prices and taxes after they've been paid for and shipped. : ) This is why "cart refreshing" (which in turn triggers the recalculation) is only automated through the cart module for orders in a cart status.
However, I'm pretty sure we had another issue open to make this a manual option for non-cart orders. In other words, I still think you should be able to recalculate prices for non-cart orders, but we shouldn't automate it at all. It should be a specific submit button on the order edit form that refreshes the items on the order... in fact, I'd almost want to put a confirmation form on it to make sure it didn't get clicked / submitted accidentally.
If anyone digs up the other issue, we can close this one as duplicate and link it from the other issue... otherwise, maybe I was just imagining having posted an issue for it. Quite possible... : P
Comment #7
pcambrarszrama I don't find the issue neither... maybe we discussed it only via IRC because I remember talking with you about it :)
Comment #8
essbee CreditAttribution: essbee commentedAgree having the ability to trigger manually for non cart statuses would be a good thing and would resolve issues raised here.
Comment #9
rszrama CreditAttribution: rszrama commentedComment #10
essbee CreditAttribution: essbee commentedWhat needs to be called in order to recalculate the order totals?
I can manipulate prices in non-cart state orders, and the line totals update, but the order totals, taxes etc do not.
Is this as simple as making a call to a price calc routine?
From a UX perspective, wouldnt it make sense when the Unit price field is edited, and the order is a non-cart status, to apply an "edit-changed" state to the form, with the typical yellow highlighted box advising that changes will be saved and order totals will be updated once the order is saved.
This way the administrator is aware that manipulating the price will change the order total (although I struggle to picture a use case where one would want to manipulate the price of an order line item without updating the order totals).
Comment #11
essbee CreditAttribution: essbee commentedI'm marking this a duplicate of http://drupal.org/node/1124414 as I think that issue more succinctly explains the issue of totals/taxes not being recalculated
Comment #12
essbee CreditAttribution: essbee commentedReopening as not fixed by the fix for http://drupal.org/node/1124414
Comment #13
essbee CreditAttribution: essbee commentedWhy can't I simply change the trigger for the rule: "Calculate taxes: Sales tax".
the "Calculating the sell price of a product" event only occurs through cart statuses, and further will reset any manual price overrides. What is preventing me from moving this routine say to the "After an Order is Saved/After an order is updated event. This would ensure that taxes were always calculated on orders, even if they did not go through the cart system.
This would certainly provide a far more flexible system - allowing administrators to place tax routines wherever was appropriate for their use case.
Ideas greatly appreciated.
Sam
Comment #14
rszrama CreditAttribution: rszrama commentedLooks like someone else came in with some code for this feature, so let's close this one as duplicate.
See: #1645252: Allow administrators to trigger "checkout completed"