Magento-如何在结帐过程中向订单添加发票费用 [英] Magento - How do I add an invoice fee to an order during checkout process

查看:49
本文介绍了Magento-如何在结帐过程中向订单添加发票费用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过我的付款模块将发票费用添加到订单中?我想应该在结帐过程中通过我的付款方式模型来完成此操作.也许我应该创建商品/产品并将其添加到购物车/报价/订单对象?

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.

在配置节点<global><sales><quote><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中将以下内容添加到<global> ...

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_quotesales_flat_order表修改为

In your module's setup, modify the sales_flat_quote and sales_flat_order tables to add a payment_fee column.

配置中的<after>值负责确定计算顺序,它可以是用逗号分隔的总计代码列表,包括税",折扣"等.您也可以指定出于相同目的的价值. 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-如何在结帐过程中向订单添加发票费用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆