I've been searching online for some help with this and found that DrByte has a code that you can put in freeshipper.php; however, it seems that it only works for various regions with a postal code that begins in letters [BD1]. The original code is below, and the second code is the one that I have modified for what I am looking for. But the modified version is not working and I don't know what is wrong with it or what I am doing wrong.
It was meant to do free shipping in a Canadian area.Code:if ($check_flag == false) { $this->enabled = false; } // check to see if postal code is in list of allowed codes: } else { $free_ship_postcodes = array('L1S','L1T','L1V','L1W','L1X','L1Y','L1Z','L3P','L3R','L3S','L3T','L4A','L4B','L4C','L4E','L4H','L4J','L4K','L4L','L4S','L4T','L4V','L4W','L4X','L4Y','L4Z','L5A','L5B','L5C','L5E','L5G','L5H','L5J','L5K','L5L','L5M','L5N','L5P','L5R','L5S','L5T','L5V','L5W','L6A','L6B','L6C','L6E','L6G','L6P','L6R','L6S','L6T','L6V','L6W','L6X','L6Y','L6Z','L7A','M1B','M1C','M1E','M1G','M1H','M1J','M1K','M1L','M1M','M1N','M1P','M1R','M1S','M1T','M1V','M1W','M1X','M2H','M2J','M2K','M2L','M2M','M2N','M2P','M2R','M3A','M3B','M3C','M3H','M3J','M3K','M3L','M3M','M4A','M4B','M4C','M4E','M4G','M4H','M4J','M4K','M4L','M4M','M4N','M4P','M4R','M4S','M4T','M4V','M4X','M4Y','M5A','M5B','M5C','M5E','M5G','M5H','M5J','M5K','M5L','M5M','M5N','M5P','M5R','M5S','M5T','M5V','M5W','M5X','M6A','M6B','M6C','M6E','M6G','M6H','M6J','M6K','M6L','M6M','M6N','M6P','M6R','M6S','M7A','M7Y','M8V','M8W','M8X','M8Y','M8Z','M9A','M9B','M9C','M9L','M9M','M9N','M9P','M9R','M9V','M9W'); $customer_postcode = $order->delivery['postcode']; $check3digitcode = substr($customer_postcode, 0, 3); $valid_digits = in_array($check3digitcode, $free_ship_postcodes); if ($valid_digits) $this->enabled = true; } }
From what I can tell, the code is not reading for letters or numbers, just to match characters, but even with the simple change it is not working. I have also tried adding a space to the end of the array and making the substring match to the 5th space...I don't know if that makes any kind of difference. I have also tried removing the array as I only have one postal code to match.Code:// check to see if postal code is in list of allowed codes: } else { $free_ship_postcodes = array('84601'); $customer_postcode = $order->delivery['postcode']; $check4digitcode = substr($customer_postcode, 0, 4); $valid_digits = in_array($check4digitcode, $free_ship_postcodes); if ($valid_digits) $this->enabled = true;
It seems that other people have tried modifying the code for an all numeral postal code with more digits than it was originally intended for, but none of them have been able to get it to work either. I'd appreciate any insight on the above code.
Bookmarks