Skip to content
Snippets Groups Projects
Commit 8797ebbf authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Version 2.4.7: Convert postal code to uppercase before checking/extracting...

Version 2.4.7: Convert postal code to uppercase before checking/extracting UK/Canadian postal code parts
parent 340cf724
Branches
Tags
No related merge requests found
BASE=rules_shipping
BASE_ADV=rules_shipping_advanced
PLUGINTYPE=vmshipment
VERSION=2.4.6
VERSION=2.4.7
PLUGINFILES=$(BASE).php $(BASE)_base.php $(BASE).script.php $(BASE).xml index.html
PLUGINFILES_ADV=$(BASE_ADV).php $(BASE)_base.php $(BASE_ADV).script.php $(BASE_ADV).xml index.html
......
File added
File added
......@@ -6,7 +6,7 @@
<authorUrl>http://www.open-tools.net</authorUrl>
<copyright>Copyright (C) 2013, Reinhold Kainhofer</copyright>
<license>GPL v3+</license>
<version>2.4.6</version>
<version>2.4.7</version>
<description>VMSHIPMENT_RULES_DESC</description>
<files>
<filename plugin="rules_shipping">rules_shipping.php</filename>
......
......@@ -42,10 +42,11 @@ class plgVmShipmentRules_Shipping_Advanced extends plgVmShipmentRules_Shipping_B
*/
protected function addCustomCartValues (VirtueMartCart $cart, $cart_prices, &$values) {
$values['coupon'] = $cart->couponCode;
$zip=strtoupper($values['zip']);
// 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"
if ($values['zip'] and preg_match('/^\s*(([A-Za-z]{1,2})(\d{1,2})([A-Za-z]?)|[A-Za-z]{4})\s*(\d[A-Za-z]{2})\s*$/', $values['zip'], $match)) {
if ($zip and preg_match('/^\s*(([A-Za-z]{1,2})(\d{1,2})([A-Za-z]?)|[A-Za-z]{4})\s*(\d[A-Za-z]{2})\s*$/', $zip, $match)) {
$values['uk_outward'] = $match[1];
$values['uk_area'] = $match[2];
$values['uk_district'] = $match[3];
......@@ -59,7 +60,7 @@ class plgVmShipmentRules_Shipping_Advanced extends plgVmShipmentRules_Shipping_B
$values['uk_inward'] = NULL;
}
// Postal code Check for Canadian postal codes: Use regexp to determine if ZIP structure matches and also to extract the parts.
if ($values['zip'] and preg_match('/^\s*(([A-Za-z])(\d)([A-Za-z]))\s*(\d[A-Za-z]\d)\s*$/', $values['zip'], $match)) {
if ($zip and preg_match('/^\s*(([A-Za-z])(\d)([A-Za-z]))\s*(\d[A-Za-z]\d)\s*$/', $zip, $match)) {
$values['canada_fsa'] = $match[1];
$values['canada_area'] = $match[2];
$values['canada_urban'] = $match[3];
......
......@@ -6,7 +6,7 @@
<authorUrl>http://www.open-tools.net</authorUrl>
<copyright>Copyright (C) 2013, Reinhold Kainhofer</copyright>
<license>GPL v3+</license>
<version>2.4.6</version>
<version>2.4.7</version>
<description>VMSHIPMENT_RULES_ADV_DESC</description>
<files>
<filename plugin="rules_shipping_advanced">rules_shipping_advanced.php</filename>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment