-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shipping methods do not work after order recalculation #75
Comments
Yeah, this is a tricky scenario in that when a cart has been completed, we switch from live rates to a snapshot rate. I have a feeling that re-calculating the order essentially ditches the snapshot data. This is because Commerce treats most shipping methods like they're defined under Commerce > Shipping, and Postie-provided live rates are a bit second-class. I'll investigate further what we can do. |
@engram-design thank you for looking into this. |
So this was slightly related to #29 (comment) where we introduced handling for completed orders. But that was some time ago, and now with Commerce's "Recalculate order" functionality this has posed an issue. Originally, our handling of completed orders was to not fetch live rates, but still return all available shipping methods enabled for the provider in Postie. These were returned as $0 due to it not being live rates. This was mainly so you could access a ShippingMethod model on the order However, I've changed this in b6eb38a to only return the shipping method picked before completing the order, and with the proper price. This should prevent issues when recalculating the order total. As an aside, it does beg the question whether live rates should be allowed when editing an order. It makes sense in case the customer decides to change their shipping method from say "regular" to "express" which would effect the cost. However, this might be difficult in practice, as there's no current way of being able to detect when you're editing a completed order in the control panel, and whether you're just viewing the order. We certainly don't want to fetch live rates when viewing an order (which it would currently do if we removed this "completed order" check), but there are cases you want to pick a live rate. Commerce would need a way of notifying us when you're editing a completed order through the control panel (via Vue) so we could access that in Postie (PHP). Looking at how they handle the edit order functionality, this currently isn't possible. |
Description
During the creation of a cart, I am receiving the correct shipping methods with rates (FedEx), and when I select a shipping method a shipping adjuster is added correctly to the cart. I can also save the cart and edit it and still receive the correct shipping methods with rates and select them.
After marking the same cart as completed (turning the cart into an order) and then recalculating it the previously added shipping method disappears from the order and under the "Shipping Method" dropdown I can see all my enabled FedEx services and none of them I am able to add to the order.
After a quick debugging of the Craft Commerce recalculation method, it looks like that during the order recalculation all the enabled shipping services (methods) in Postie are automatically added to the "Shipping Method" dropdown with a 0 rate, and none of them are trying to fetch the new rates from the Postie's provider (FedEx).
Steps to reproduce
Additional info
Additional context
Postie configuration:
The text was updated successfully, but these errors were encountered: