Prestashop shipping cost by state

不羁岁月 提交于 2019-12-22 11:24:55

问题


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:

  1. Go to Localization->Zones
  2. Created new different Zones according to State. eg. Zone name = "NSW"
  3. Go to Localization->States
  4. Choose state and change it's new zone. eg. "New South Wales" now changed into "NSW" zone.
  5. Go to Shipping->Carriers
  6. Click on "Edit" on shipping method.
  7. Click on "Shipping Locations and Costs"
  8. Now change shipping cost by each zone which has now related states.


来源:https://stackoverflow.com/questions/10027122/prestashop-shipping-cost-by-state

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!