Skip to content

fix(core,starter): make the postcode optional at checkout - #140

Open
moset15 wants to merge 1 commit into
emdashCommerce:mainfrom
FIKANOVA:fix/checkout-postcode-optional
Open

moset15 wants to merge 1 commit into
emdashCommerce:mainfrom
FIKANOVA:fix/checkout-postcode-optional

Conversation

@moset15

@moset15 moset15 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Part of the roadmap in #108.

Problem

Shipping zones match on country and region only (matchesZone); the postcode never picks a rate. Many addresses have no postcode (most Kenyan ones, for example), yet checkout requires one:

  • cart/shipping-location answers 400 postalCode required;
  • checkout/create-session answers 409 "Pick a ship-to country and postal code before paying."

Change

  • Both routes need only the country. A postcode that is given is trimmed and stored, because table tax rates can match on a postcode prefix.
  • HostedCheckoutForm: the postcode field is marked "(optional)" and is no longer required; the hint reads "Enter your country, and your postal code if you have one".
  • The starter's embedded (Stripe Elements) form: the shipping and billing postcode fields are marked optional. The billing one is no longer required when billing differs from shipping.
  • cart/contact never checked the postcode and is unchanged.
  • Patch changeset for core and the starter.

Tests

packages/core/test/postcode-optional.test.ts, through the real routes:

  • cart/shipping-location accepts { country: "ke" } and stores KE with an empty postcode (fails without the change);
  • it keeps a given postcode, trimmed;
  • it still refuses a missing country;
  • checkout/create-session starts a payment for a shipped cart with no postcode (fails without the change);
  • it still refuses a shipped cart with no country;
  • the starter's form marks both postcode fields optional and requires neither.

Rebased on current main: core 440 pass (the 4 local routing-response-adapter failures pass on CI), typecheck clean; bun.lock is unchanged.

Tested by hand: a Kenyan address with no postcode got shipping options and a paid Paystack order.

Shipping zones match on country and region only, and many addresses
have no postcode, but cart/shipping-location answered 400 without one
and checkout/create-session refused a ship-to address without one.
Both now need only the country; a postcode that is given is still
stored for postcode-prefix tax rates. The postcode fields in
HostedCheckoutForm and the starter's embedded form (shipping and
billing) are marked optional and no longer required.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@moset15
moset15 force-pushed the fix/checkout-postcode-optional branch from cec44fa to 11d2ff3 Compare December 5, 2026 22:53
@moset15
moset15 marked this pull request as ready for review December 5, 2026 22:53
@moset15

moset15 commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

#107 has landed, so this is rebased onto main and ready for review.

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