Linux 软件免费装
Banner图

Sri Lankan Cities for WooCommerce

开发者 lakshan12
更新时间 2026年7月3日 15:44
PHP版本: 7.4 及以上
WordPress版本: 7.0
版权: GPLv2 or later
版权网址: 版权信息

标签

woocommerce checkout districts postcode sri lanka

下载

1.0.0

详情介绍:

WooCommerce ships Sri Lanka with no districts and the State field hidden. This plugin makes checkout work the way Sri Lankan addresses actually work: 101, Main Street, Negombo, Gampaha, 11500, Sri Lanka. Safety and design Data provenance Every autofilled postal code was verified against Sri Lanka Post and independent directories (July 2026). Cities whose codes could not be fully verified are left out — for those, the city field simply works as a plain text box.

安装:

  1. Install and activate from Plugins → Add New Plugin (or upload the zip via Upload Plugin).
  2. WooCommerce 8.9 or newer must be active.
  3. Done — districts, city suggestions and postcode autofill work immediately on checkout. The plugin has no settings page of its own; the Settings link on the Plugins screen takes you to WooCommerce's shipping settings, where the districts appear as zone regions.
Upgrading from the code-snippet version: if you previously installed this as a snippet (FluentSnippets, a child theme's functions.php, or an mu-plugin file), remove that copy BEFORE activating the plugin. Both loaded at once causes a duplicate-function PHP error.

屏幕截图:

  • Pick a known city and the postal code fills in automatically — shipping switches to the matching district zone.
  • The block checkout is fully supported: district, city suggestions and postcode autofill.
  • Ship by district — districts appear as regions in WooCommerce → Settings → Shipping.

升级注意事项:

1.0.0 If you used the old code-snippet version, remove the snippet before activating the plugin — both at once causes a duplicate-function error.

常见问题:

How do I add my own cities?

Use the slwc_city_data filter from your child theme or a small snippet: add_filter( 'slwc_city_data', function ( $data ) { $data['LK-12']['My Village'] = '11123'; // district code => city => postcode return $data; } ); District keys are ISO 3166-2:LK codes (the full list is in the District dropdown at checkout). Keep postcodes as quoted 5-digit strings — leading zeros matter.

Does it work with the block checkout?

Yes. Both the classic shortcode checkout and the block checkout are supported; block updates go through WooCommerce's official wp.data store API.

What if a customer's city is not in the list?

Nothing breaks: the city field keeps working as a normal text box and the customer types their postcode manually.

Can I ship by district?

Yes — the districts appear as regions in WooCommerce → Settings → Shipping → Add zone, so you can price shipping per district.

更新日志:

1.0.0