Skip to content

Accept UK postcodes with a space on the shipping step (ENG-412) - #24

Open
agoldis wants to merge 1 commit into
demo/harbor-pine-shopfrom
fix/eng-412-uk-postcode-space
Open

agoldis wants to merge 1 commit into
demo/harbor-pine-shopfrom
fix/eng-412-uk-postcode-space

Conversation

@agoldis

@agoldis agoldis commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Fixes ENG-412: checkout rejected UK postcodes typed with a space.

Cause: the GB format in shipping.mjs (/^[A-Z]{1,2}\d[A-Z\d]?\d[A-Z]{2}$/) has no space, so POST /api/shipping-rates with SW1A 1AA returned 422 invalid_postcode, and the shipping step showed "Sorry, we can't deliver to this address."

Fix: quoteShipping removes whitespace and upper-cases the postcode before checking it. SW1A 1AA and sw1a1aa now get delivery options; a partial postcode such as SW1A is still rejected.

Verified:

  • curl against the local shop: SW1A 1AA returns both GB rates, SW1A returns 422.
  • Browser run of the support session's steps: delivery options show, total £46.95, "Continue to payment" enabled. Screenshots and session links are in the comment below.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

The GB postcode format only matched the compact form, so "SW1A 1AA"
returned 422 invalid_postcode and checkout showed "Sorry, we can't
deliver to this address." Remove whitespace and upper-case the postcode
before checking it against the country format.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@agoldis

agoldis commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Before and after for SW1A 1AA on the shipping step.

  • Before (support session, failed): https://s.crts.sh/ai/FrRi7bf2xxA3Fagk. POST /api/shipping-rates returns 422 invalid_postcode, "Sorry, we can't deliver to this address.", Continue to payment disabled.
  • After (this branch, passed): https://s.crts.sh/ai/OgUWMzmtf4yHsMmV. Royal Mail Tracked 48 and DPD Next Day shown, total £46.95, Continue to payment enabled, no console errors or failed requests.

Screenshots attached: cant-deliver-sw1a.png (before), delivery-options-sw1a.png (after).

cant-deliver-sw1a

delivery-options-sw1a

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