2013-02-18 96 views

回答

3

唉,得到了答案。從應用程序/代碼/核心/法師/運輸/型號/電信/ Flatrate.php
文件副本 - >本地/法師/運輸/型號/電信/ 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); 


應用程序/代碼/核心/法師/運輸的/ 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> 

創建在應用程序/代碼/核心/法師/運輸/型號/來源/ 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')), 
     ); 
    } 
} 

我希望這可以幫助別人。

+1

我覺得system.xml部分是錯誤的,它應該引用shipperType,而不是handlingType。除此之外,這是一個巨大的幫助。 – iJeep 2013-05-02 18:52:57

+0

@iJeep:謝謝。指出它。那麼system.xml現在已經更新了。 – 2013-05-03 05:44:03

+0

請避免更改核心文件,更好的方法是按照本教程的建議操作:http://www.smashingmagazine.com/2014/01/15/create-custom-shipping-methods-magento/ – 2014-11-13 16:26:35