Magento關於自定義運費插件Magento_Custom_Shipping-master的使用

在我們運營magento網站的過程中,有時候要根據快遞的運送速度讓客戶選擇不同快遞
那麼這裏我向大家推薦一款簡單易用的的插件Magento_Custom_Shipping-master

插件下載可以看看我們發佈另一篇關於開發中常用的插件介紹, 裏面有下載鏈接
目前插件只支持兩種運送方式
首先找到Magento_Custom_Shipping-master/app/code/community/Inchoo/Shipping/Model/Carrier.php
這裏定義了兩種方式,你可以自由選擇,比如我們要設置一個快一個慢

/**
     * Get Standard rate object
     *
     * @return Mage_Shipping_Model_Rate_Result_Method
     */
    protected function _getStandardRate()
    {
        /** @var Mage_Shipping_Model_Rate_Result_Method $rate */
        $rate = Mage::getModel('shipping/rate_result_method');

        $rate->setCarrier($this->_code);
        $rate->setCarrierTitle($this->getConfigData('title'));
        $rate->setMethod('large');
        $rate->setMethodTitle('Standard delivery (5-9 Working days)');
        $rate->setPrice(25);
        $rate->setCost(0);

        return $rate;
    }

    /**
     * Get Express rate object
     *
     * @return Mage_Shipping_Model_Rate_Result_Method
     */
    protected function _getExpressRate()
    {
        /** @var Mage_Shipping_Model_Rate_Result_Method $rate */
        $rate = Mage::getModel('shipping/rate_result_method');

        $rate->setCarrier($this->_code);
        $rate->setCarrierTitle($this->getConfigData('title'));
        $rate->setMethod('express');
        $rate->setMethodTitle('Fast delivery USA ONLY (3-5 Working days)');
        $rate->setPrice(30);
        $rate->setCost(0);

        return $rate;
    }

簡單說明下幾個參數
$rate->setMethodTitle 設置標題
$rate->setPrice 設置運費

安裝成功之後效果如下在這裏插入圖片描述
自行測試。。。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章