Jump to content

Carrier by zip/postcode


Recommended Posts

I am trying figure out how to show carrier by zip/postcode i am using prestashop 1.5.6.1

 

for e,g if customer has postcode 12345, 38484 or 82293 than only carrier A should be shown

 

if customer has postcode 11111, 22222, or 33333 than only carrier B Should be shown

 

I have found code given below in internet 

 

To select the carrier / delivery method in PrestaShop by the postal code of the delivery address, create a file Address.php in /override/classes with this content:

<?phpclass Address extends AddressCore{    protected static function getPostcodeByAddress($id_address) {        $row = Db::getInstance()->getRow('            SELECT `postcode`            FROM '._DB_PREFIX_.'address a            WHERE a.`id_address` = '.(int)($id_address));        return $row['postcode'];    }    public static function getZoneById($id_address)    {        $postcode = self::getPostcodeByAddress($id_address);        if (in_array($postcode, Array(1050)))            return 1;        elseif (in_array($postcode, Array(2000)))            return 10;        return 0;    [spam-filter]

In this example, postal code 1050 is assigned to the carrier with ID 1 and postal code 2000 is assigned to carrier ID 10 (see the carrier list in the backend for the ID numbers).

Because the solution uses the PrestaShop override mechanism, it will survive version updates.

Tested with PrestaShop 1.4.7.0.

 

also tried solution given at 

 

http://www.prestashop.com/forums/topic/160695-solved-carrier-by-postcode-the-easy-way/

 

 

But none of these work with prestashop 1.5.6.1 above solution are tested on 1.4 how to make this work in 1.5.6.1

 

 

 

Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...