Replace a republished shipping option, and reset the manifest per cart - #2693
Draft
kha333n wants to merge 1 commit into
Draft
Replace a republished shipping option, and reset the manifest per cart#2693kha333n wants to merge 1 commit into
kha333n wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2691.
The same code is on
2.xatManifests/ShippingManifest.php, so this wants aforward 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 insteadof returning without doing anything. That is what makes a re-priced option stick.
getOptions()starts with a clean collection when the cart being resolvedchanges. 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.phpand seven others — andthat 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()istable-rate-shipping'smodifier, so nothing outside the tests depends on the old behaviour.
Tests
tests/core/Unit/Base/ShippingManifestTest.php:500 then 2500. Fails on
1.xwithFailed asserting that 500 matches expected 2500.the same process. Fails on
1.xwithFailed asserting that actual size 1 matches expected size 0.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.