Skip to content

Replace a republished shipping option, and reset the manifest per cart - #2693

Draft
kha333n wants to merge 1 commit into
lunarphp:1.xfrom
kha333n:fix/shipping-manifest-stale-options
Draft

Replace a republished shipping option, and reset the manifest per cart#2693
kha333n wants to merge 1 commit into
lunarphp:1.xfrom
kha333n:fix/shipping-manifest-stale-options

Conversation

@kha333n

@kha333n kha333n commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Fixes #2691.

The same code is on 2.x at Manifests/ShippingManifest.php, so this wants a
forward port.

A modifier that re-prices an option has its answer discarded, and in any process
handling more than one cart the next cart is offered the last one's options.

The fix

Two changes, one for each half of it.

addOption() replaces an option whose identifier is already present instead
of returning without doing anything. That is what makes a re-priced option stick.

getOptions() starts with a clean collection when the cart being resolved
changes
. Resetting unconditionally would have been simpler, but much of the
suite publishes straight onto the manifest rather than from inside a modifier —
tests/Pest.php, tests/stripe/Utils/CartBuilder.php and seven others — and
that usage is legitimate. Resetting on a change of cart leaves it working while
still giving each cart a manifest of its own. There is a test pinning that.

In shipped code the only caller of addOption() is table-rate-shipping's
modifier, so nothing outside the tests depends on the old behaviour.

Tests

tests/core/Unit/Base/ShippingManifestTest.php:

  • can replace an option that is published again — the same identifier at
    500 then 2500. Fails on 1.x with
    Failed asserting that 500 matches expected 2500.
  • can not offer one cart the options priced for another — a second cart in
    the same process. Fails on 1.x with
    Failed asserting that actual size 1 matches expected size 0.
  • can keep options published for the cart being resolved — an option added
    directly, then two resolves of that same cart. Passes before and after, and is
    the guard that this does not break the way the suite sets shipping up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

The shipping manifest keeps stale options: a re-priced option is discarded, and one cart sees another's

1 participant