When the shipping rate widget calculates the prices to display (the radio list of shipping options), PromotionSubscriber::onCalculate() previews each rate's discounted price on a clone of the order. But $order->createDuplicate() copies the order's adjustments field — including the order-level shipping adjustment that LateOrderProcessor had already added for the previously selected rate.
That stale shipping cost inflates the clone's total. Since $promotion->applies($fake_order) evaluates promotion conditions against that total (e.g. an order_total_price condition like "total ≤ €30"), the wrong total flips the result — so rates in the widget get discounted when they shouldn't (or vice-versa).
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | checkout.png | 312.49 KB | nicolasgraph |
| #7 | promotion.png | 163.17 KB | nicolasgraph |
| #5 | 3330729-5-fix-wrongly-adjusted-shipping-rates-in-rate-widget.patch | 1.01 KB | nicolasgraph |
Issue fork commerce_shipping-3330729
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
nicolasgraphHere is a tiny patch.
Comment #3
nicolasgraphThe two first test failures are the same as 2.x-dev, however the two second ones needs attention.
Comment #4
nicolasgraphComment #5
nicolasgraphWe don't need to clear all adjustments; removing an already applied shipping adjustment is enough and avoids disappearance of adjustments in the order summary on page refreshment.
Comment #6
jsacksick commentedWould be great if we could get tests for this. Could you describe a bit what this fixes exactly? Steps to reproduce your issue at least?
Comment #7
nicolasgraphThanks for your reply @jsacksick; I've edited the initial post in order to clarify the issue.
Comment #8
nicolasgraphComment #9
nicolasgraphComment #11
nicolasgraphI included the patch + a test into the MR. I also updated the issue description, to clarify the bug.
Comment #13
jsacksick commentedI wanted to merge this, but I'm wondering why we haven't updated the existing PromotionSubscriberTest. IF you can't get to it, I'll try to move the new test method there.
Comment #15
jsacksick commented