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

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

本文介绍了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.
ThenShipping 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收取运费占小计的百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 13:37