Page 1 of 2 12 LastLast
Results 1 to 10 of 21

Hybrid View

  1. #1
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Free Shipping Based on Postal Code Zone?

    Try this:

    1. In /includes/modules/shipping/freeshipper.php, insert some new code, as shown:
    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;
          }
        }
    2. Enable the "freeshipper" module in Admin->Modules->Shipping

    And give it a try.

    If it works for you, consider a donation.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  2. #2
    Join Date
    Jun 2008
    Posts
    23
    Plugin Contributions
    0

    Default Re: Free Shipping Based on Postal Code Zone?

    Quote Originally Posted by DrByte View Post
    Try this:

    1. In /includes/modules/shipping/freeshipper.php, insert some new code, as shown:
    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;
          }
        }
    2. Enable the "freeshipper" module in Admin->Modules->Shipping

    And give it a try.

    If it works for you, consider a donation.
    Dr. Byte,

    I have four words for you, You are the MAN!!

    Your code works like a charm! It was easy to implement and works perfectly.
    I have also have to send you kudos for your Canadian Tax Classes and Rates Config thread, again, as I have said before, easy to understand and easy to put to work.

    Now I have to decide if I am going with the Canada Post module or just going flat rate in my paid shipping, I also have to work out my IE css sheets so that everything looks just as great as it does in Firefox.

    Thank you, thank you, thank you,
    A donation will be forthcoming and the praises of Zen Cart and Dr. Byte shall rise from the depths of my gratitude.

    Thanks again and have a great day,
    Jim
    Each day is an opportunity to be happy!

  3. #3
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Free Shipping Based on Postal Code Zone?

    Sometimes I get one right here or there.
    Thanks for confirming that it worked for you!
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  4. #4
    Join Date
    Sep 2008
    Posts
    49
    Plugin Contributions
    0

    Default Re: Free Shipping Based on Postal Code Zone?

    Hey Dr Byte & winter - exactly the topic i was looking for....

    I have tried the above code but it seems to throw an error in there. I droped the code at the end of the free_shipper but have error displaying on line 115

    } else {

    ...any thoughts? also when it is installed a loose all but 2 of the shipping methods and the edit button (side display) completely dissapears.

    Its for the same purpose as above, specific to a 3 digit uk postal code cv1,cv2,cv3,cv4,cv5,cv6,cv7 ... any thoughts would be greatly appreciated!

    Matt

  5. #5
    Join Date
    Sep 2008
    Posts
    49
    Plugin Contributions
    0

    Default Re: Free Shipping Based on Postal Code Zone?

    Quote Originally Posted by Maccon View Post
    Hey Dr Byte & winter - exactly the topic i was looking for....

    I have tried the above code but it seems to throw an error in there. I droped the code at the end of the free_shipper but have error displaying on line 115

    } else {

    ...any thoughts? also when it is installed a loose all but 2 of the shipping methods and the edit button (side display) completely dissapears.

    Its for the same purpose as above, specific to a 3 digit uk postal code cv1,cv2,cv3,cv4,cv5,cv6,cv7 ... any thoughts would be greatly appreciated!

    Matt
    Ok I have inserted it in teh rightplace now (he says in hope...) will post back if any problems and likewise if successful! :)

  6. #6
    Join Date
    Sep 2008
    Posts
    49
    Plugin Contributions
    0

    Default Re: Free Shipping Based on Postal Code Zone?

    Update: I have dropped this code inoto a test site i have however this has led to another query.

    1> The option doesnt seem to pick up if the shipping address differs to the registered address...any thoughts?
    Last edited by Maccon; 14 Oct 2008 at 01:34 PM.

  7. #7
    Join Date
    Sep 2008
    Posts
    49
    Plugin Contributions
    0

    Default Re: Free Shipping Based on Postal Code Zone?

    Quote Originally Posted by Maccon View Post
    Update: I have dropped this code inoto a test site i have however this has led to another query.

    1> The option doesnt seem to pick up if the shipping address differs to the registered address...any thoughts?
    ok so its due to teh case sensitive issue. have created a new thread http://www.zen-cart.com/forum/showthread.php?t=110632 with another problem!

  8. #8

    Default Re: Free Shipping Based on Postal Code Zone?

    Quote Originally Posted by DrByte View Post
    Try this:

    1. In /includes/modules/shipping/freeshipper.php, insert some new code, as shown:
    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;
          }
        }
    2. Enable the "freeshipper" module in Admin->Modules->Shipping

    And give it a try.

    If it works for you, consider a donation.


    Dr Byte,

    The code you made seems to be very useful for me as I happened to have the same predicament with Jim/New Zenner regarding free shipping within a specified territory. I tried to replace the 3-digit codes with 4-digit codes of ours but it seems it doesn't work for me. Here is the code that i modified:

    // check to see if postal code is in list of allowed codes:
    } else {
    $free_ship_postcodes = array('4328, 4031, 4329, 4327, 4032, 4005');
    $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;
    // END OF CODE

    Is this right? I have no idea about Php yet but I know a little on programming. I tried to modify all the setting on shipping modules and the configuration but still it doesnt work for me. Im not sure if i placed it exactly in the right code position in the Php file.

    Am i right that the idea is to have freeshipper available only to those listed in the code? But for other postal codes i tested, freeshipper works which is not what i wanted to do!

    Hope you could help me sort things out. Thanks a lot.

    Francis

  9. #9
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Free Shipping Based on Postal Code Zone?

    I haven't studied your PHP code, but I did spot this problem:
    $free_ship_postcodes = array('4328, 4031, 4329, 4327, 4032, 4005');
    Each value in that array should be in quotes separately, like this:
    Code:
    $free_ship_postcodes = array('4328', '4031', '4329', '4327', '4032', '4005');
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  10. #10

    Default Re: Free Shipping Based on Postal Code Zone?

    Quote Originally Posted by DrByte View Post
    Each value in that array should be in quotes separately, like this:
    Code:
    $free_ship_postcodes = array('4328', '4031', '4329', '4327', '4032', '4005');
    Hi Dr. Byte,

    I appreciate your effort. I changed and tried to install, remove and re-install again all the available options but still i can not get my desired result.

    What i wanted to achieve is to set the free shipper module to just 6 towns in the Philippines thus the need for the zip code filter or any other field perhaps.. then for the rest of the Philippines i want a flat rate shipping and zone shipping for the rest of the world. The last 2 works correctly but free shipping applies in all other towns or cities of the Philippines even they are not in the list. I even set up new zones for the 6 towns but still free shipping does not work as I want it to be.

    Thanks for your time and effort. I appreciate it a lot. I guess i will have to take a break for a while on this and consider other options.


    Francis

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Validate registration based on postal code?
    By sandragrills in forum Basic Configuration
    Replies: 2
    Last Post: 30 May 2011, 03:22 PM
  2. Free shipping to a single postal code
    By Angelica in forum Built-in Shipping and Payment Modules
    Replies: 6
    Last Post: 24 May 2011, 01:38 AM
  3. Zone Shipping Price based on Postal Code
    By lioncity in forum General Questions
    Replies: 2
    Last Post: 10 Oct 2009, 03:43 PM

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