如何在prestashop载体模块开发中插入不同的运输成本

时间:2017-10-20 12:06:40

标签: php prestashop prestashop-1.7

在我的控制器中,我有运费的成本价值。我试图将其发送到getOrderShippingCost功能。但我的购物车显示出货free

Controller.php这样

$cost_val=120; //this value can be change

include_once(_PS_MODULE_DIR_.'delivery_scheduler/delivery_scheduler.php');

    $DeliveryWeekSched=new delivery_scheduler();

    $DeliveryWeekSched->getOrderShippingCost($cost_val,$cost_val);

delivery_scheduler.php

public function getOrderShippingCost($params, $shipping_cost)
    {
        if (Context::getContext()->customer->logged == true)
        {
            $id_address_delivery = Context::getContext()->cart->id_address_delivery;
            $address = new Address($id_address_delivery);
            return 100; // i want to return `$shipping_cost`
        }
        return $shipping_cost;
    }

在购物车中显示$shipping_cost时返回free运费值。当100返回购物车运费值显示100时。为什么会这样?如何返回我的价值?

1 个答案:

答案 0 :(得分:0)

您可以通过将运营商的额外费用(例如tax和handling_rates)设置为零来解决此问题,然后设置为"不免费"