问题
Is there by any chance a way to set shipping cost by state in a carrier in prestashop?
i.e. let's say i want a different shipping cost to send in Alabama than in Alaska with the same carrier
Thanks
回答1:
There are a couple ways of doing this. You can purchase an external module, such as this one, or create an override like so:
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;
}
回答2:
This worked for me:
- Go to Localization->Zones
- Created new different Zones according to State. eg. Zone name = "NSW"
- Go to Localization->States
- Choose state and change it's new zone. eg. "New South Wales" now changed into "NSW" zone.
- Go to Shipping->Carriers
- Click on "Edit" on shipping method.
- Click on "Shipping Locations and Costs"
- Now change shipping cost by each zone which has now related states.
来源:https://stackoverflow.com/questions/10027122/prestashop-shipping-cost-by-state