【问题标题】:how to add custom fields in magento payment module如何在 magento 支付模块中添加自定义字段
【发布时间】:2012-02-27 07:54:45
【问题描述】:

我从博客下载了一个模块,它工作正常。但我需要再添加两个文本框。

 class Excellence_Pay_Block_Info_Pay extends Mage_Payment_Block_Info
    {
        protected function _prepareSpecificInformation($transport = null)
        {
            if (null !== $this->_paymentSpecificInformation) {
                return $this->_paymentSpecificInformation;
            }
            $info = $this->getInfo();
            $transport = new Varien_Object();
            $transport = parent::_prepareSpecificInformation($transport);
            $transport->addData(array(
                Mage::helper('payment')->__('Voucher #') => $info->getCheckNo(),
                Mage::helper('payment')->__('Voucher Date') => $info->getCheckDate(),
                Mage::helper('payment')->__('Field Date') => $info->getCheckField(), //custom field
                Mage::helper('payment')->__('Field new') => $info->getCheckField1() //custom field
            ));
            return $transport;
        }
    }

I change the code to this in block/info, and change some code in model/pay.php




public function assignData($data)
        {
            if (!($data instanceof Varien_Object)) {
                $data = new Varien_Object($data);
            }
            $info = $this->getInfoInstance();
            $info->setCheckNo($data->getCheckNo())
            ->setCheckDate($data->getCheckDate())
            ->setCheckField($data->getCheckField())
            ->setCheckField1($data->getCheckField1());
            return $this;
        }

并添加一些代码 etc/config.xml

<fieldsets>
             <sales_convert_quote_payment>
                <check_no>
                    <to_order_payment>*</to_order_payment>
                </a>
                <check_date>
                    <to_order_payment>*</to_order_payment>
                </check_date>
                <check_field>
                    <to_order_payment>*</to_order_payment>
                </check_field>
                <check_field1>
                    <to_order_payment>*</to_order_payment>
                </check_field1>
             </sales_convert_quote_payment>
        </fieldsets>

但它不起作用。 .我还更新了数据库并在 pay.phtml 中添加了一些输入文本框。

【问题讨论】:

    标签: magento


    【解决方案1】:

    请参考之前在此处回答的相同问题

    Magento Payment Info Block

    Saving extra data with an order in Magento

    【讨论】:

    • 感谢您的快速响应。但我对代码做了一些小修改,它运行得很好。
    猜你喜欢
    • 2013-02-10
    • 1970-01-01
    • 2011-03-10
    • 2013-08-13
    • 2013-10-11
    • 1970-01-01
    • 2014-10-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多