我正在开发 magento 1.7。我正在开发支付网关,我已经添加了发票费用现在我必须在税组中添加发票费用的税金
请任何人帮助解决这个问题这里是按照我的代码我试图在税款中添加税额但仍然无法正常工作可能是我做错了什么
<?php
class ***_******_Model_Quote_TaxTotal
extends Mage_Sales_Model_Quote_Address_Total_Tax
{
public function collect(Mage_Sales_Model_Quote_Address $address)
{
$quote = $address->getQuote();
if (($quote->getId() == null)
|| ($address->getAddressType() != "shipping")
) {
return $this;
}
$payment = $quote->getPayment();
if (($payment->getMethod() != 'invoice')
&& (!count($quote->getPaymentsCollection()))
) {
return $this;
}
try {
/**
* Instead of relying on hasMethodInstance which would not always
* work when i.e the order total is reloaded with coupon codes, we
* try to get the instance directly instead.
*/
$methodInstance = $payment->getMethodInstance();
} catch (Mage_Core_Exception $e) {
return $this;
}
if (!$methodInstance instanceof Mage_Payment_Model_Method_Abstract) {
return $this;
}
if ($methodInstance->getCode() != 'invoice') {
return $this;
}
$fee = $methodInstance->getAddressInvoiceFee($address);
if(Mage::getStoreConfig('payment/invoice/tax_class') == '' ){
return $this;
}
$invoiceFee = $baseInvoiceFee = Mage::getStoreConfig('payment/invoice/_fee');
$fee = Mage::helper('invoice')->getInvoiceFeeArray($invoiceFee, $address, null);
if (!is_array($fee)) {
return $this;
}
$address->setTaxAmount($address->getTaxAmount() + 5454+ $fee['taxamount']);
$address->setBaseTaxAmount(
$address->getBaseTaxAmount() + 5454+ $fee['base_taxamount']
);
$address->setInvoiceTaxAmount($fee['taxamount']);
$address->setBaseInvoiceTaxAmount($fee['base_taxamount']);
return $this;
}
}
这是 config.xml
<sales>
<quote>
<totals>
<fee>
<class>invoice/sales_quote_address_total_fee</class>
</fee>
<invoicetax>
<class>invoice/quote_taxTotal</class>
<after>subtotal,discount,shipping,tax</after>
<before>grand_total</before>
</invoicetax>
</totals>
</quote>
</sales>