Skip to content

Ignore a postcode tax zone that scores no match - #2684

Open
kha333n wants to merge 1 commit into
lunarphp:1.xfrom
kha333n:fix/postcode-tax-zone-zero-score
Open

Ignore a postcode tax zone that scores no match#2684
kha333n wants to merge 1 commit into
lunarphp:1.xfrom
kha333n:fix/postcode-tax-zone-zero-score

Conversation

@kha333n

@kha333n kha333n commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Fixes #2683.

The same code is unchanged on 2.x, so this wants a forward port.

A customer shipping to the UAE with postcode SW1A 0AA is charged a Sheffield
rate, because the store happens to have a zone on S1 2AB.

The fix

$match is the array ['postcode' => …, 'matches' => 0], which is truthy even
when nothing matched — so the "give up" branch below it was unreachable. The
guard now reads the score inside it, which is the value that says whether the
zone applies at all.

Nothing else changes: the candidate query, the wildcard scoring and the sort are
all untouched, so a zone that does match still wins exactly as before.

Tests

tests/core/Unit/Actions/Taxes/GetTaxZonePostcodeTest.php:

  • can not match a postcode that only shares a first character — a store with
    a single S1 2AB zone, asked for SW1A 0AA. Fails on 1.x, which returns the
    S1 2AB row.
  • can still match a wildcard when a non-matching zone shares the first
    character
    S1 2AB and SW* together; SW* still wins. Passes before and
    after, and is the guard that the fix rejects non-matches rather than weakening
    matching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

A postcode tax zone is returned for postcodes it does not match, suppressing the country and default zones

1 participant