Skip to content

Refetch shipping on coupon application - #1441

Open
pbennett1-godaddy wants to merge 6 commits into
fix-billing-collection-logicfrom
refetch-shipping-on-coupon-application
Open

Refetch shipping on coupon application#1441
pbennett1-godaddy wants to merge 6 commits into
fix-billing-collection-logicfrom
refetch-shipping-on-coupon-application

Conversation

@pbennett1-godaddy

@pbennett1-godaddy pbennett1-godaddy commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Ensure discount changes correctly reconcile shipping rates and taxes without duplicate requests or stale totals.

Discounts can change shipping eligibility, including enabling or disabling free shipping. The checkout now refetches shipping methods after a successful discount change when a valid shipping
destination is available. It determines whether the returned rates require shipping reconciliation and assigns the final tax calculation to either the discount or shipping workflow, ensuring taxes run
exactly once.

This PR also improves shipping defaults and express checkout discount synchronization.

Key changes

  • Refetch shipping methods after applying or removing a discount when a complete shipping destination is available.
  • Skip shipping-rate and tax requests when no valid shipping or billing destination exists.
  • Separate core discount and shipping mutations from their workflow side effects.
  • Reapply applicable discounts after a shipping-method change before calculating taxes.
  • Calculate taxes once:
    • From the discount workflow when shipping remains unchanged.
    • From the shipping workflow when a new method must be applied.
  • Select the cheapest shipping method when the returned rate set changes, including newly available free shipping.
  • Avoid unnecessary shipping mutations when the cheapest method is already selected.
  • Preserve the current selection when the available rate set is unchanged.
  • Remove obsolete client-side free-shipping experimental-rule filtering; the shipping API is now authoritative for rate eligibility.
  • Synchronize order, line-item, and shipping-line discount codes with GoDaddy and Stripe express checkout shadow orders.
  • Prevent duplicate express PriceAdjustments requests caused by unrelated draft-order updates.
  • Show express checkout for shipping-enabled sessions without depending on temporary PURCHASE fulfillment state.
  • Continue hiding express checkout for digital-only orders while allowing it for pickup or purchase fulfillment when shipping is enabled.

Changeset

  • Changeset added (docs)

Test Plan

  • Added coverage for discount application when shipping rates remain unchanged.
  • Added coverage for paid shipping becoming free after a discount.
  • Added coverage for a newly available free method becoming the default.
  • Added coverage ensuring shipping reconciliation completes before the single tax request.
  • Added coverage for applying, reapplying, and removing shipping-line discounts.
  • Added coverage for applying a coupon before an address is available.
  • Added coverage for shipping-method selection and reconciliation decisions.
  • Added coverage for collecting order, line-item, and shipping-line discount codes for express checkout.
  • Added coverage for express checkout visibility across shipping, purchase-fulfillment, digital-only, and pickup scenarios.
  • Updated free-order coverage for automatic selection of the cheapest shipping method.
  • Verified the complete browser flow for:
    • Discount application with unchanged shipping.
    • Discount removal with unchanged shipping.
    • Discount application enabling free shipping.
    • Shipping-specific coupon application and method changes.
    • A fresh checkout without an address.

Validation completed:

  • pnpm --filter @godaddy/react typecheck
  • pnpm --filter @godaddy/react test
  • 59 test files passed
  • 586 tests passed

@pbennett1-godaddy
pbennett1-godaddy requested a review from a team as a code owner August 26, 2026 16:45
@changeset-bot

changeset-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b64fff2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@godaddy/react Patch
nextjs Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pbennett1-godaddy
pbennett1-godaddy changed the base branch from main to fix-billing-collection-logic August 26, 2026 16:57
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.

1 participant