根据折扣/优惠券代码在Magento中设置税率
问题描述:
我一直试图根据所使用的优惠代码为magento设置税率或客户类率。我只使用折扣代码,因为我可以使用它作为输入。根据折扣/优惠券代码在Magento中设置税率
有没有人有任何想法这可以实现或任何指针?
亲切的问候
克里斯
答
这就是我最终为此做的。应该证明相当有用。将此文件复制应用程序/代码/核心/法师/税务/型号/ 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];
}
干杯这个
答
有这样做的没有默认的方式。您应该通过管理员为他们设置客户的班级,这样他们就可以始终获得特定的税率,而无需输入任何内容。
+0
为答案发条干杯,我已经想通过calculate.php做到这一点。它本质上是修改核心代码,但我将它与产品税类结合起来,以获得我想要的。将尝试记住在此处发布代码。谢谢 – Knade 2011-01-11 14:10:24
帮助不该税率由国家和产品,而不是客户来设置? – 2011-01-11 09:52:44
在这种情况下,客户的一个案例必须明确说明他们对这些特定产品免税。 – Knade 2011-01-12 10:55:21