Jump to content

Set shipping cost based on states


Recommended Posts

Hi, 

I am looking for a way to change the shipping fee, to adjust the cost by states of my country

I tried to follow this tutorial, but it gives me an internal error, (parse error for the bold text)

 

So can anyone help me ? how to correct it or any other way to do?

 

I tried to pass by fee by zone, but 1 country can't belong to many zones, so it doesn't help

 

Thank you

 

 

1) Copy "classes/Address.php" to "override/classes/Address.php". 2) In line 28 change class name from AddressCore to Address 3) Before function getZoneById, paste this new function

/**
* Return postcode of address
*
* @param $id_address Address id
* @return integer postcode
*/
public 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'];
}

4) Add before first line of function getZoneById this:

$postcode=self::getPostcodeByAddress($id_address);

if(in_array($postcode,array(your list of postcodes)){
return id-of-your-zone;

}else 

Link to comment
Share on other sites

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