ECSHOP內置的配送插件運費規則有兩種模式,一種是按重量計算(fee_compute_mode == ‘by_weight’),另一種是按商品件數計算(fee_compute_mode == ‘by_number’)。
按重量計算規則=首重費用+續重費用。大多數快遞均以1000克為計量單位,EMS以500克為單位計算。
配送插件文件位置:/includes/modules/shipping/,運費計算函數如下:
/**
*計算訂單的配送費用的函數
*
*@paramfloat$goods_weight商品重量
*@paramfloat$goods_amount商品金額
*@paramfloat$goods_number商品件數
*@returndecimal
*/
functioncalculate($goods_weight,$goods_amount,$goods_number)
{
if($this->configure['free_money']>0&&$goods_amount>=$this->configure['free_money'])
{
return0;
}
else
{
@$fee=$this->configure['base_fee'];
$this->configure['fee_compute_mode']=!empty($this->configure['fee_compute_mode'])?$this->configure['fee_compute_mode']:'by_weight';
if($this->configure['fee_compute_mode']=='by_number')//按商品件數計算
{
$fee=$goods_number*$this->configure['item_fee'];
}
else//按商品重量計算
{
if($goods_weight>1)
{
$fee+=(ceil(($goods_weight-1)))*$this->configure['step_fee'];
}
}
return$fee;
}
}
calculate函數有三個必要參數,商品重量是按重量計算運費的參數,商品件數是按商品件數計算運費的參數,而商品金額用來確定是否符合免運費條件。
新聞熱點
疑難解答