Skip to content

Discount every shipping group in the discount template - #664

Merged
kirakik merged 4 commits into
Shopify:mainfrom
robertcooper-shopify:delivery-discount-every-group
Nov 5, 2026
Merged

kirakik merged 4 commits into
Shopify:mainfrom
robertcooper-shopify:delivery-discount-every-group

Conversation

@robertcooper-shopify

@robertcooper-shopify robertcooper-shopify commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

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 SHIPPING option. 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 as LOCAL. Checkout never mixes pickup and shipping options in one group, so the template keeps its deliveryGroup targets and only adds deliveryOptions { 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_UP options, the shipping group with only SHIPPING options, and the shipping group as the only target. I didn't tophat the TypeScript or Rust versions.

@robertcooper-shopify
robertcooper-shopify marked this pull request as ready for review November 4, 2026 18:45
@robertcooper-shopify robertcooper-shopify changed the title Discount every delivery group in the discount template Discount every shipping group in the discount template Nov 4, 2026
return {operations: []};
}

// A split cart can list the pickup group first, so check every group.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this assumption publicly documented and something we guarantee? I wouldn't set any expectation: partners should just filter to keep what they need.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pickup group order isn't guaranteed. Should I just remove the comment?

@kirakik
kirakik merged commit c23ca2f into Shopify:main Nov 5, 2026
4 checks passed
@robertcooper-shopify
robertcooper-shopify deleted the delivery-discount-every-group branch November 6, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants