【问题标题】:magento charge shipping as percentage of subtotalmagento 收取运费占小计的百分比
【发布时间】:2013-02-18 09:51:15
【问题描述】:


想要根据百分比计算运费,这也可以通过管理员进行管理。
例如:- 运费 [ADMIN]:10
如果小计 = 100。
那么 运费 = 10。
提前致谢。

【问题讨论】:

    标签: magento shipping


    【解决方案1】:

    唉,得到了答案。
    文件从 app/code/core/Mage/Shipping/Model/Carrier/Flatrate.php 复制到 --> local/Mage/Shipping/Model/Carrier/Flatrate.php
    关于第 96 行的相应编辑:

    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 行]

                    <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')),
            );
        }
    }
    

    我希望这对某人有所帮助。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-11-29
    • 2021-10-31
    • 1970-01-01
    • 2012-02-28
    • 1970-01-01
    • 1970-01-01
    • 2018-08-03
    相关资源
    最近更新 更多