KSA National Address Validator

Description

This plugin enhances the WooCommerce checkout experience by adding a “National Address Short Code” field. When a customer enters their 8-character short code, the plugin communicates with the OTO National Address API to fetch and automatically populate the checkout address fields (City, District, Street Address, etc.).

Features

  • Adds a National Address Short Code field to the WooCommerce checkout page (Classic and Blocks).
  • Field is shown only when Saudi Arabia is selected as the billing country.
  • Validates the format of the short code (4 letters followed by 4 digits, e.g. ABCD1234).
  • Fetches address details from the OTO API and auto-fills City, District, Street, Postcode fields.
  • Optional: mark the field as required for Saudi Arabia orders only (non-SA orders are never blocked).
  • Connect/disconnect via email and password login (supports 2FA/TOTP).
  • Caches the API access token (55 minutes) to minimise API calls.
  • Compatible with WooCommerce High-Performance Order Storage (HPOS).
  • Fully compatible with both Classic checkout and WooCommerce Blocks checkout.

External services

This plugin connects to the OTO API to validate Saudi Arabian National Address short codes and retrieve address details during WooCommerce checkout.

What this service does

The OTO National Address API validates 8-character Saudi National Address short codes (e.g., ABCD1234) and returns the corresponding address information including city, district, street name, building number, and postal code. This data is used to automatically populate checkout address fields for customers in Saudi Arabia.

Data transmitted

During plugin authentication (admin settings page):
– Email address and password are sent to authenticate with the OTO API
– If 2FA is enabled, the one-time password (OTP) code is also sent
– A refresh token is returned and stored to maintain the connection

During checkout validation (when customer enters a short code):
– The National Address short code entered by the customer is sent to the API
– An access token (obtained via the stored refresh token) is sent for authentication
– Address data is returned and used to populate checkout fields

Service provider

This service is provided by OTO Global.

Installation

  1. Upload the ksa-national-address-validator folder to the /wp-content/plugins/ directory, or install directly from the WordPress.org plugin directory.
  2. Activate the plugin through the ‘Plugins’ menu in WordPress.
  3. Go to WooCommerce KSA Validator (or Settings KSA Validator) and click Connect.
  4. Enter your OTO account email and password to authenticate. If your account uses two-factor authentication (2FA), select “2FA Enabled: Yes” and enter your OTP code.
  5. Once connected, the National Address Short Code field will appear automatically on the checkout page when Saudi Arabia is selected as the billing country.

FAQ

Where do I get an OTO account?

You can sign up for an OTO account at https://tryoto.com/.

Does this work with the WooCommerce Blocks checkout?

Yes. The plugin supports both the Classic checkout and the modern WooCommerce Blocks checkout out of the box.

Will non-Saudi Arabia customers be affected?

No. The shortcode field is hidden for all non-SA billing countries and validation is completely skipped for non-SA orders, even when the “required” setting is enabled.

Reviews

There are no reviews for this plugin.

Contributors & Developers

“KSA National Address Validator” is open source software. The following people have contributed to this plugin.

Contributors

Changelog

1.2.2

  • Fixed: “Required” setting now correctly blocks Blocks checkout submission for Saudi Arabia orders when shortcode field is empty
  • Fixed: Non-SA countries can now complete Blocks checkout without being incorrectly blocked by the required shortcode validation
  • Fixed: Classic checkout no longer enforces shortcode required validation for non-Saudi Arabia orders on server-side
  • Fixed: Blocks checkout field now shows native required indicator (*) when the required setting is enabled
  • Improved: Required field validation is now country-aware for both Classic and Blocks checkout engines

1.2.1

  • Changed plugin prefix from ksa_nav_ to otoksa_ for WordPress.org compliance (minimum 4 characters required)
  • Updated all PHP classes, functions, options, AJAX actions, and JavaScript globals to use new prefix
  • Maintains backward compatibility with existing installations using old prefix
  • Order meta display checks both old and new key formats

1.2.0

  • Added “Set Shortaddress Field Required” setting for checkout validation
  • Added External Services documentation for WordPress.org compliance
  • Fixed all prefixing issues for WordPress.org guidelines compliance
  • Improved uninstall cleanup for options and transients
  • Removed unnecessary WooCommerce logger modification

1.1.0

  • feat: Integrate OTO National Address API and enhance validation
  • feat: Add loading spinner and refine client-side validation
  • fix: Clear access token cookie if API key is empty
  • feat: Add CSS for KSA National Address Shortcode styling
  • feat: Swap buildingName and streetName mapping

1.0.0

  • Initial release.