Problem/Motivation
When the estimate is performed, we "clone" the order, rather than calling the createDuplicate() method which clears the order ID.
I believe this is necessary so that the initial order isn't affected.
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | interdiff_19-20.txt | 3.09 KB | jsacksick |
| #20 | 3251240-20.patch | 18.67 KB | jsacksick |
| #19 | 3251240-19.patch | 16.97 KB | jsacksick |
| #18 | interdiff_17-18.txt | 637 bytes | jsacksick |
| #18 | 3251240-18.patch | 20.23 KB | jsacksick |
Comments
Comment #2
jsacksick commentedComment #3
jsacksick commentedThis patch can't work as commerce_shipping is complaining about a missing order_id when proposed shipment value objects are being created... So this would require additional work in commerce_shipping.
Comment #5
jsacksick commentedThis is causing shipments to be duplicated (See #3250006: Multiple Duplicate Shipments).
Comment #6
tomtech commentedThis patch strives to make the cart estimate temporal, avoiding any entity saves.
Note: this depends on
commerce_shippinghaving this patch in place: #3279815-2: Allow LateOrderProcessor to skip shipment savesThis also resolves the related issues: #3239478: Save order items after recalculation and #3253596: Reset owned_by_packer flag during cart estimation
Comment #7
tomtech commentedComment #8
tomtech commentedChanged
shouldSave()to accept ShipmentInterface rather than OrderInterface.Comment #9
jsacksick commentedDo we really need to set the inner class here since we are not using it?
Also, I'm still in favor of defining a custom order refresh service as discussed, instead of decorating the existing one, so we can just invoke it ourselves and don't have to worry about running it for regular orders or not?
Another note, you can also just swap the late order processor and extend the base order processor, via a service provider, just overridding the
shouldSave()method.Comment #10
jsacksick commentedMade several changes, also shortened the exception class names (no need to prefix by CartEstimate since we have namespaces).
Went with a custom order refresh as mentioned in #9, added a composer.json to require commerce_shipping dev so we can test this.
Also, we need to expand the
EstimatorTestto assert that the order is not modified/saved etc etc.Comment #11
jsacksick commentedAborted the test as it seems that it was stuck in some kind of infinite loop.
Comment #12
jsacksick commentedOnce we expand a bit the EstimatorTest, we could tag a new commerce_shipping release, require this new shipping version, and commit this.
@TomTech: thoughts?
Comment #13
jsacksick commentedThese are all "blind" changes TBH. Wondering if we should skip refreshing prices though?
Experiencing the following locally:
Before the estimate:

After:

The subtotal changed, perhaps we need to refresh prices, not really sure what's missing, would need to dig a bit.
Comment #14
jsacksick commentedRealized we need to refresh prices, simply because a promotion reducing the unit price can be applied, which is what was causing the issue from the screenshot.
Comment #15
jsacksick commentedExpanded the tests to ensure the original order is not altered (checking the version and the total price to ensure they remain unaltered).
Comment #16
jsacksick commentedNot really sure whether we need custom exceptions or whether we should reuse the
CartEstimateExceptionthat already exists although it has a different "meaning".Other than that, I think we're good, I should probably tag a new commerce_shipping release and then update this patch.
Comment #17
jsacksick commentedRequire Commerce shipping 2.4 minimum.
Comment #18
jsacksick commentedComment #19
jsacksick commentedTo avoid the BC with the new OrderRefreshInterface, decided to extend the order refresh service coming from commerce_order.
Comment #20
jsacksick commentedActually seems more right to not extend the base class and simply implement the interfac, this way we don't depend on the services neeeded by the parent.
Comment #22
jsacksick commentedCommitted! @TomTech: Thanks a lot!