Skip to content

Customise UK shipping zones by black/white listing postcode ranges

Notifications You must be signed in to change notification settings

stuartbates/solidus-uk-postcode-zones

Repository files navigation

Solidus UK Postcode Zones Build Status Coverage Status

Provides the ability to customise shipping zones using postcodes - you can either:

  • Blacklist postcodes to exclude them from an existing zone
  • Whitelist postcodes to create zones made up exclusively of postcodes

Installation

In your Gemfile:

gem 'solidus_uk_postcode_zones', github: 'stuartbates/solidus-uk-postcode-zones'

Bundle your dependencies and run the installation generator:

bundle install
bundle exec rails g solidus_uk_postcode_zones:install

Examples

  • Create a new zone called United Kingdom mainland
  • Set it as a country based zone
  • Search and select United Kingdom from the country select

Scottish Highlands

Create a new country-based zone called Scottish Highlands and add the United Kingdom as its only country. Enter all the postcodes that make up the Scottish Highlands in the whitelist field:

# Scottish Highlands whitelisted postcodes
HS1-9, IV1-56, KA27-28, KW1-17, PA20-78, PH17-50, ZE1-3

Save the zone and then edit the United Kingdom mainland zone by entering the same string of postcodes you whitelisted previously in the blacklist field:

# United Kingdom Mainland blacklisted postcodes
HS1-9, IV1-56, KA27-28, KW1-17, PA20-78, PH17-50, ZE1-3

Now if a customer enters a postcode during checkout that is in the Scottish Highlands only shipping methods attached to the Scottish Highlands zone will be used to calculate delivery charges.

If you want to add another postcode based zone you need to make sure you append the whitelisted postcodes of that zone to the blacklisted postcodes on the UK mainland zone.

Northern Ireland

Create a new country-based zone called Northern Ireland and add the United Kingdom as its only country. Enter all the postcodes that make up Northern Ireland in the whitelist field:

# Northern Ireland whitelisted postcodes
BT1-99

Save the zone and then edit the United Kingdom mainland zone. This time you'll need to append the Northern Ireland postcodes to the existing blacklist:

# United Kingdom Mainland blacklisted postcodes
HS1-9, IV1-56, KA27-28, KW1-17, PA20-78, PH17-50, ZE1-3, BT1-99

Testing

First bundle your dependencies, then run rake. rake will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using bundle exec rake test_app.

bundle
bundle exec rake

About

Customise UK shipping zones by black/white listing postcode ranges

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published