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).

Command icon 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

NicolasGraph created an issue. See original summary.

nicolasgraph’s picture

Assigned: nicolasgraph » Unassigned
Status: Active » Needs review
StatusFileSize
new770 bytes

Here is a tiny patch.

nicolasgraph’s picture

Status: Needs review » Needs work

The two first test failures are the same as 2.x-dev, however the two second ones needs attention.

nicolasgraph’s picture

Issue summary: View changes
nicolasgraph’s picture

StatusFileSize
new1.01 KB

We 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.

jsacksick’s picture

Would 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?

nicolasgraph’s picture

Issue summary: View changes
StatusFileSize
new163.17 KB
new312.49 KB

Thanks for your reply @jsacksick; I've edited the initial post in order to clarify the issue.

nicolasgraph’s picture

Assigned: Unassigned » nicolasgraph
nicolasgraph’s picture

Version: 8.x-2.x-dev » 3.x-dev

nicolasgraph’s picture

Issue summary: View changes
Status: Needs work » Needs review

I included the patch + a test into the MR. I also updated the issue description, to clarify the bug.

tbkot made their first commit to this issue’s fork.

jsacksick’s picture

I 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.

jsacksick’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.