Prestashop 运费按州分列 [英] Prestashop shipping cost by state
问题描述
有没有办法在 prestashop 的承运人中按州设置运费?
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
谢谢
推荐答案
有几种方法可以做到这一点.您可以购买一个外部模块,例如这个,或创建一个覆盖 like所以:
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) 将classes/Address.php"复制到override/classes/Address.php".
1) Copy "classes/Address.php" to "override/classes/Address.php".
2) 在第 28 行,将类名从 AddressCore 更改为 Address
2) In line 28 change class name from AddressCore to Address
3) 在函数 getZoneById 之前,粘贴这个新函数
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) 在函数 getZoneById 的第一行之前添加:
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;
}
这篇关于Prestashop 运费按州分列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!