2011-01-11 169 views
1

我一直試圖根據所使用的優惠代碼爲magento設置稅率或客戶類率。我只使用折扣代碼,因爲我可以使用它作爲輸入。根據折扣/優惠券代碼在Magento中設置稅率

有沒有人有任何想法這可以實現或任何指針?

親切的問候

克里斯

+0

幫助不該稅率由國家和產品,而不是客戶來設置? – 2011-01-11 09:52:44

+0

在這種情況下,客戶的一個案例必須明確說明他們對這些特定產品免稅。 – Knade 2011-01-12 10:55:21

回答

1

這就是我最終爲此做的。應該證明相當有用。將此文件複製應用程序/代碼/核心/法師/稅務/型號/ Calculation.php到App /代碼/本地/法師/稅務/型號/ Calculation.php然後線178那裏有此功能

public function getRate($request) 
    { 
     if (!$request->getCountryId() || !$request->getCustomerClassId() || !$request->getProductClassId()) { 
      return 0; 
     } 

    $cacheKey = $this->_getRequestCacheKey($request); 
    if (!isset($this->_rateCache[$cacheKey])) { 
     $this->unsRateValue(); 
     $this->unsCalculationProcess(); 
     $this->unsEventModuleId(); 
     Mage::dispatchEvent('tax_rate_data_fetch', array('request'=>$request)); 
     if (!$this->hasRateValue()) { 
      $rateInfo = $this->_getResource()->getRateInfo($request); 
      $this->setCalculationProcess($rateInfo['process']); 
      $this->setRateValue($rateInfo['value']); 
     } else { 
      $this->setCalculationProcess($this->_formCalculationProcess()); 
     } 
     $this->_rateCache[$cacheKey] = $this->getRateValue(); 
     $this->_rateCalculationProcess[$cacheKey] = $this->getCalculationProcess(); 
    } 
    return $this->_rateCache[$cacheKey]; 
} 

我已將此更改爲此。根據我對這個項目的要求,它是一個硬編碼折扣代碼和產品稅類別標識。

public function getRate($request) 
    { 
     if (!$request->getCountryId() || !$request->getCustomerClassId() || !$request->getProductClassId()) { 
      return 0; 
     } 

    $cacheKey = $this->_getRequestCacheKey($request); 
    if (!isset($this->_rateCache[$cacheKey])) { 
     $this->unsRateValue(); 
     $this->unsCalculationProcess(); 
     $this->unsEventModuleId(); 
     Mage::dispatchEvent('tax_rate_data_fetch', array('request'=>$request)); 
     if (!$this->hasRateValue()) { 
      $rateInfo = $this->_getResource()->getRateInfo($request); 
      $this->setCalculationProcess($rateInfo['process']); 
      $thisDiscountCode = Mage::getSingleton('checkout/session')->getQuote()->getCouponCode(); 
      $thisProductClassCode = $request->getProductClassId(); 
      if($thisDiscountCode == "0000" && $thisProductClassCode == "5"): 
      $this->setRateValue(0); 
      else:  
      $this->setRateValue($rateInfo['value']); 
      endif;    
     } else { 
      $this->setCalculationProcess($this->_formCalculationProcess()); 
     } 
     $this->_rateCache[$cacheKey] = $this->getRateValue(); 
     $this->_rateCalculationProcess[$cacheKey] = $this->getCalculationProcess(); 
    } 
    return $this->_rateCache[$cacheKey]; 
} 

乾杯這個

2

有這樣做的沒有默認的方式。您應該通過管理員爲他們設置客戶的班級,這樣他們就可以始終獲得特定的稅率,而無需輸入任何內容。

+0

爲答案發條幹杯,我已經想通過calculate.php做到這一點。它本質上是修改核心代碼,但我將它與產品稅類結合起來,以獲得我想要的。將嘗試記住在此處發佈代碼。謝謝 – Knade 2011-01-11 14:10:24

相關問題