From 7115b603a90a1ac0beb45d4454a90a3a2680d01b Mon Sep 17 00:00:00 2001
From: Reinhold Kainhofer <reinhold@kainhofer.com>
Date: Sat, 2 Sep 2017 14:27:55 +0200
Subject: [PATCH] UK Postcodes: Also extract parts of UK postcodes if second
 part (inbound) is missing altogether

---
 library/rules_shipping_framework.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/library/rules_shipping_framework.php b/library/rules_shipping_framework.php
index fce5baf..b34b1a4 100644
--- a/library/rules_shipping_framework.php
+++ b/library/rules_shipping_framework.php
@@ -348,7 +348,7 @@ class RulesShippingFramework {
 		// Postal code Check for UK postal codes: Use regexp to determine if ZIP structure matches and also to extract the parts.
 		// Also handle UK overseas areas/islands that use four-letter outward codes rather than "A{1,2}0{1,2}A{0,1} 0AA"
 		$zip=strtoupper($zip);
-		if (isset($zip) and preg_match('/^\s*(([A-Z]{1,2})(\d{1,2})([A-Z]?)|[A-Z]{4}|GIR)\s*(\d[A-Z]{2})\s*$/', $zip, $match)) {
+		if (isset($zip) and preg_match('/^\s*(([A-Z]{1,2})(\d{1,2})([A-Z]?)|[A-Z]{4}|GIR|)\s*((\d|)([A-Z]{2}|))\s*$/', $zip, $match)) {
 			$values['uk_outward'] = $match[1];
 			$values['uk_area'] = $match[2];
 			$values['uk_district'] = $match[3];
-- 
GitLab