magento收取运费占小计的百分比

编程入门 行业动态 更新时间:2024-10-26 23:30:05
本文介绍了magento收取运费占小计的百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

想根据百分比来计算运输成本,该百分比也可以由管理员管理. 例如:-运输费用[ADMIN] :10 如果小计=100.然后 运费=10. 预先感谢.

Wanted to calculate a shipping cost on basis of percentage which is also manageable from admin. For E.g :- Shipping cost [ADMIN] : 10 If subtotal = 100.Then Shipping cost = 10. Thanks in advance.

推荐答案

A得到了答案. 将文件从 app/code/core/Mage/Shipping/Model/Carrier/Flatrate.php 复制到-> local/Mage/Shipping/Model/Carrier/Flatrate.php > 关于第96行,进行相应的修改:

Alas got the answer. File copy from app/code/core/Mage/Shipping/Model/Carrier/Flatrate.php to --> local/Mage/Shipping/Model/Carrier/Flatrate.php About line 96 edit accordingly:

if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) { $shippingPrice = '0.00'; } //code starts here if ($this->getConfigData('shipper_type') == 'P') { $session = Mage::getSingleton('checkout/session'); $quote_id = $session->getQuoteId(); $item_quote = Mage::getModel('sales/quote')->load($quote_id); $shippingPrice = $item_quote->getSubtotal()*($this->getConfigData('price')/100); //code ends here } $method->setPrice($shippingPrice); $method->setCost($shippingPrice);

在 app/code/core/Mage/Shipping/etc/system.xml中. [关于行:181]

In app/code/core/Mage/Shipping/etc/system.xml. [About line : 181]

<shipper_type translate="label"> <label>Calculate Shipping Fee</label> <frontend_type>select</frontend_type> <source_model>shipping/source_shipperType</source_model> <sort_order>4</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>0</show_in_store> </shipper_type>

创建在app/code/core/mage/Shipping/Model/Source/ShipperType.php中

class Mage_Shipping_Model_Source_ShipperType { public function toOptionArray() { return array( array('value' => Mage_Shipping_Model_Carrier_Abstract::HANDLING_TYPE_FIXED, 'label' => Mage::helper('shipping')->__('Fixed')), array('value' => Mage_Shipping_Model_Carrier_Abstract::HANDLING_TYPE_PERCENT, 'label' => Mage::helper('shipping')->__('Percent')), ); } }

我希望这对某人有帮助.

I hope this helps someone.

更多推荐

magento收取运费占小计的百分比

本文发布于:2023-11-22 09:52:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1616959.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:小计   百分比   运费   magento

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!