Magento 定制运费

发布于 2024-12-21 11:23:30 字数 193 浏览 0 评论 0原文

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

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

Is there a way to add a custom shipping rate for to basket (order) in magento not from admin but in programing.

What I need is, I will have a field with each product "shipping_cost" , now suppose customer added 3 products to basket, now the shipping cost of the order will be the highest of shipping_costs of the products. For example, the 3 products have shipping_costs like $10, $20 and $30 , so the shipping_cost for basket will be $30.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沐歌 2024-12-28 11:23:30

是的,根据您的情况,您需要获取最高运费并将该值分配给 $shippingprice。您可以使用给定代码在 magento 中添加订单的自定义运费:

$order = Mage::getModel('sales/order')->load($incrementId, 'increment_id');
    
$shippingprice = 30;
    
$order->setShippingAmount($shippingprice);
    
$order->setBaseShippingAmount($shippingprice); 
$order->setGrandTotal($order->getGrandTotal() + $shippingprice); //adding shipping price to grand total
    
$order->save();

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

Yes, in your condition you need to get maximum shipping rate and assign that value to $shippingprice. You can add your custom shipping price for an order in magento using given code:

$order = Mage::getModel('sales/order')->load($incrementId, 'increment_id');
    
$shippingprice = 30;
    
$order->setShippingAmount($shippingprice);
    
$order->setBaseShippingAmount($shippingprice); 
$order->setGrandTotal($order->getGrandTotal() + $shippingprice); //adding shipping price to grand total
    
$order->save();

It will update your shipping price and grand total. I guess it will be helpful to you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文