Repository navigation
Discount every shipping group in the discount template - #664
Merged
kirakik merged 4 commits intoNov 5, 2026
Merged
Conversation
robertcooper-shopify
marked this pull request as ready for review
November 4, 2026 18:45
loic-d
reviewed
Nov 4, 2026
| return {operations: []}; | ||
| } | ||
|
|
||
| // A split cart can list the pickup group first, so check every group. |
There was a problem hiding this comment.
Is this assumption publicly documented and something we guarantee? I wouldn't set any expectation: partners should just filter to keep what they need.
Contributor
Author
There was a problem hiding this comment.
Pickup group order isn't guaranteed. Should I just remove the comment?
loic-d
approved these changes
Nov 4, 2026
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.
The discount template's delivery function only discounted
deliveryGroups[0]. A cart that splits into a shipping group and a pickup group can list the pickup group first, so the free delivery discount lands on pickup and shipping keeps its full price.The JavaScript, TypeScript and Rust templates now check every delivery group and discount only the groups with a
SHIPPINGoption. Local pickup, local delivery and pickup point groups don't get the discount, and an inline comment marks where to add other delivery methods such asLOCAL. Checkout never mixes pickup and shipping options in one group, so the template keeps itsdeliveryGrouptargets and only addsdeliveryOptions { deliveryMethodType }to the input query.A cart with no shipping groups, or no delivery groups at all, now returns no operations instead of throwing
No delivery groups found. There's nothing to discount in that case, and most delivery discount apps already return no operations there rather than failing the Function run.The tests cover a split cart in both orders, a pickup-only cart, a cart with local delivery and pickup point groups (no discount), and a cart with no groups. The Rust template had no tests for this function, so it gets the same seven.
Tophat
I deployed the equivalent JavaScript delivery function (the discounts reference app's copy) to a test store and checked out a ship-and-pickup split with the pickup group first. Before this change, only pickup got FREE DELIVERY and shipping stayed at $13.80. With it, shipping is free and pickup gets no discount. The Function run log shows the pickup group with only
PICK_UPoptions, the shipping group with onlySHIPPINGoptions, and the shipping group as the only target. I didn't tophat the TypeScript or Rust versions.