【问题标题】:Magento custom shipping costMagento 定制运费
【发布时间】:2011-12-16 13:35:29
【问题描述】:

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

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

请帮帮我。

【问题讨论】:

    标签: magento shipping


    【解决方案1】:

    是的,在您的条件下,您需要获得最大运费并将该值分配给$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();
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-10
      • 1970-01-01
      • 2015-09-12
      • 2015-12-20
      • 2012-02-28
      • 2012-12-05
      • 2014-04-03
      • 1970-01-01
      相关资源
      最近更新 更多