2013-05-08 109 views
-1

我已經爲運輸方法集成了矩陣費率模塊。但我有額外的要求如何在Magento中顯示動態運費價格?

用於通過更改倉庫選項顯示動態運費價格。

例如,我有2個倉庫A和B.當用戶選擇倉庫A,然後

航運價格應該相應地被更新。和倉庫B的相同案例。

我很困惑我應該怎麼做?

請幫忙。

回答

0

我正在努力尋求類似的要求。我必須根據用戶選擇郵資方式來設定運費。

這裏是我我繼續,如果它可以幫助你:

  1. 創建自定義的運輸方式,它可以讓用戶選擇倉庫/郵資/不管。它將顯示在OnePageCheckout送貨方式步驟中。您可以輕鬆創建新的送貨方式,只需Google即可。

  2. if($_rate->getCode()=='yourmodule_code')條件放入模板/結帳/ shipping_method/available.phtml ,然後編寫用戶可以看到的單選按鈕的代碼。例如。對於Warehouse1和Warehouse2。

  3. 基於用戶選擇設置使用collectRates運費率的模塊()方法[您已覆蓋]這樣

    public function collectRates(Mage_Shipping_Model_Rate_Request $request) { 
         $result = Mage::getModel('shipping/rate_result'); 
         if($show){ 
    
         $method = Mage::getModel('shipping/rate_result_method'); 
         $method->setCarrier($this->_code); 
         $method->setMethod($this->_code); 
         $method->setCarrierTitle($this->getConfigData('title')); 
         $method->setMethodTitle($this->getConfigData('name')); 
         $method->setPrice($price); //this price you can get from available.phtml using AJAX 
         $method->setCost($price); 
         $result->append($method); 
    
        }else{ 
         $error = Mage::getModel('shipping/rate_result_error'); 
         $error->setCarrier($this->_code); 
         $error->setCarrierTitle($this->getConfigData('name')); 
         $error->setErrorMessage($this->getConfigData('specificerrmsg')); 
         $result->append($error); 
        } 
        return $result; 
    } 
    

希望它能幫助。