问题描述
如何使用我的付款模块向订单添加发票费用?我想这应该在结账过程中通过我的付款方式模型完成.也许我应该创建一个项目/产品并将其添加到购物车/报价单/订单对象?
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 - 如何在结帐过程中向订单添加发票费用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!