問題描述
如何使用我的付款模塊向訂單添加發票費用?我想這應該在結賬過程中通過我的付款方式模型完成.也許我應該創建一個項目/產品并將其添加到購物車/報價單/訂單對象?
How do I add an invoice fee to an order with my payment module? I guess this should be done during the checkout process through my payment method model. Perhaps I should create and add an item/product to the cart/quote/order object?
我不知道如何做這些事情.請幫忙
I don't know how to do any of these things though. Please help
推薦答案
雖然它可能不適合虛偽的人.以下是向總計區域添加一條線的粗略步驟,然后將您的費用添加到總計中.
Although possible it is not for the feint-hearted. Here is a rough run-down of the steps to add a line to the totals area, which will then add your fee to the grand total.
在配置節點
添加一個新條目(參見 app/code/core/Mage/Sales/etc/config.xml
更多例子)
In the config node <global><sales><quote><total>
add a new entry (see app/code/core/Mage/Sales/etc/config.xml
for more examples)
<paymentFee>
<class>yourmodule/quote_address_total_paymentFee</class> <!-- A model -->
<after>subtotal</after>
</paymentFee>
還在 config.xml
中添加以下內容到
...
Also in the config.xml
add the following to <global>
...
<fieldsets>
<sales_convert_quote>
<payment_fee><to_order>*</to_order></payment_fee>
</sales_convert_quote>
</fieldsets>
創建模型來計算費用.
class Your_Module_Model_Quote_Address_Total_Warranty extends Mage_Sales_Model_Quote_Address_Total_Abstract
{
public function __construct()
{
$this->setCode('paymentFee');
}
public function collect(Mage_Sales_Model_Quote_Address $address)
{
// Check the payment method in use, if it is yours do...
$address->setPaymentFee($fee);
return $this;
}
public function fetch(Mage_Sales_Model_Quote_Address $address)
{
if ($address->getPaymentFee()) {
$address->addTotal(array(
'code' => $this->getCode(),
'title' => 'Your module payment message',
'value' => $address->getPaymentFee()
));
}
return $this;
}
}
在您的模塊設置中,將 sales_flat_quote
和 sales_flat_order
表修改為 添加payment_fee 列.
In your module's setup, modify the sales_flat_quote
and sales_flat_order
tables to add a payment_fee column.
config 中的 值負責確定計算順序,可以是逗號分隔的總計代碼列表,包括tax"、discount"等. 出于相同的目的,您也可以指定
值.fetch()
方法中的 $address->addTotal
將完成更新總計的工作,這是向客戶收取的費用.有必要更改報價和訂單表,以便記錄您收取的費用并向管理員顯示.
The <after>
value in the config is responsible for determining the order of calculation, it can be a comma-separated list of totals' codes including "tax", "discount", etc. You may also specify a <before>
value for the same purposes. The $address->addTotal
in fetch()
method will do the work of updating the grand total, which is what the customer will be charged. It is necessary to alter the quote and order tables so the fee you have charged is recorded and shown to the admin.
如果默認渲染器不行,也可以指定自己的渲染器,我也這樣做過,但更復雜.
It is also possible to specify your own renderer if the default will not do, I have done this also but is even more complex.
這篇關于Magento - 如何在結帳過程中向訂單添加發票費用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!