Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2011
    Posts
    23
    Plugin Contributions
    0

    Default Free shipping to a single postal code

    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.

    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;
          }
        }
    It was meant to do free shipping in a Canadian area.


    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;
    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.

    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.

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Free shipping to a single postal code

    What are you trying to do?

    You give a 5 digit zip code: 84601

    But you are trying to squeeze that into 4 digits ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  3. #3
    Join Date
    Feb 2011
    Posts
    23
    Plugin Contributions
    0

    Default Re: Free shipping to a single postal code

    Oh, well I tried it with 5 places as well, but that didn't work either. But for an explanation, I was thinking the count started with 0 so it would be 0, 1, 2, 3, 4 rather than 1, 2, 3, 4, 5.

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Free shipping to a single postal code

    If I use 0, 5 with that Zip Code, I see the Free Shipping ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  5. #5
    Join Date
    Feb 2011
    Posts
    23
    Plugin Contributions
    0

    Default Re: Free shipping to a single postal code

    hmm... do you think it makes a difference that my products are being bought by someone who ships it to someone else? So there are two differing postal codes, the customers and the shipment? I wouldn't think so, but I honestly don't know why the code isn't working for me.

  6. #6
    Join Date
    Feb 2011
    Posts
    23
    Plugin Contributions
    0

    Default Re: Free shipping to a single postal code

    I take it back! It works just fine now. I forgot that I removed the array but then I didn't change the call on the array. But thank you very very much for correcting the 4 and 5. Between a few things, I wouldn't have been able to actually work it out. I'm still working on learning more about php and everything else for that matter.

  7. #7
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Free shipping to a single postal code

    You are most welcome thanks for the update that this is working for you ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

 

 

Similar Threads

  1. Free Shipping Based on Postal Code Zone?
    By wintercard in forum Addon Shipping Modules
    Replies: 20
    Last Post: 22 Jun 2011, 02:25 PM
  2. Shipping rate by postal code
    By bainne in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 28 Mar 2009, 02:07 AM
  3. Shipping Help Postal Code
    By odessey1 in forum Addon Shipping Modules
    Replies: 5
    Last Post: 7 Feb 2009, 12:02 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR