Magento定制运费

时间:2011-12-16 13:35:29

标签: magento shipping

有没有办法在magento中为购物篮(订单)添加自定义运费,而不是从管理员添加,而是在编程中。

我需要的是,我将为每个产品“shipping_cost”设置一个字段,现在假设客户将3个产品添加到购物篮中,现在订单的运费将是产品的shipping_costs中最高的。例如,3种产品的运费分别为10美元,20美元和30美元,因此购买篮子的shipping_cost将为30美元。

请帮帮我。

1 个答案:

答案 0 :(得分:0)

是的,在您的条件中,您需要获得最高运费并将该值分配给$shippingprice。您可以使用给定代码为magento中的订单添加自定义运费: -

    $order = Mage::getModel('sales/order')->load($increamentId, 'increment_id');

    $shippingprice = 30;

    $order->setShippingAmount($shippingprice);

    $order->setBaseShippingAmount($shippingprice); 
$order->setGrandTotal($order->getGrandTotal() + $shippingprice); //adding shipping price to grand total

    $order->save();

它会更新您的运费和总价。我想这会对您有所帮助。