将自定义字段添加到付款方式

时间:2019-06-21 10:57:12

标签: magento

我在下面重复了检查操作 如下所示将其复制到checkmonew。我正在使用Magento 1.9.3版

第1步:法师/付款/冻结/表格+信息:将checkmo.php复制到checkmonew.php(将内部checkmo重命名为checkmonew)

第2步:法师/付款/e​​tc/config.xml + system.xml:复制checkmo部分(并将其重命名为checkmonew)

第3步:法师/付款/模型/方法:将checkmo.php复制到checkmonew.php(将内部checkmo重命名为checkmonew)

第4步:设计/管理html /默认/默认/模板/付款/表格+信息:将checkmo.php复制到checkmonew.php(将内部checkmo重命名为checkmonew)

第5步:设计/前端/基础/默认/模板/付款/表格+信息: 将checkmo.php复制到checkmonew.php(在checkmo内部重命名为checkmonew)

现在,这一切似乎都可行,但是由于某种原因,仅在后端运行,而checkmo在前端显示,没问题。

我还想在新的付款方式中添加抄送类型选项。我希望它不是下拉列表,而只是从CC付款方式中使用的cc类型卡列表中进行选择。

谢谢

admin inmage

代码

阻止-信息

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category    Mage
 * @package     Mage_Payment
 * @copyright  Copyright (c) 2006-2017 X.commerce, Inc. and affiliates (http://www.magento.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */


class Mage_Payment_Block_Info_Cashmonew extends Mage_Payment_Block_Info
{

    protected $_payableTo;
    protected $_mailingAddress;

    protected function _construct()
    {
        parent::_construct();
        $this->setTemplate('payment/info/Cashmonew.phtml');
    }

    /**
     * Enter description here...
     *
     * @return string
     */
    public function getPayableTo()
    {
        if (is_null($this->_payableTo)) {
            $this->_convertAdditionalData();
        }
        return $this->_payableTo;
    }

	  protected function _prepareSpecificInformation($transport = null)
    {
        if (null !== $this->_paymentSpecificInformation) {
            return $this->_paymentSpecificInformation;
        }
        $transport = parent::_prepareSpecificInformation($transport);
        $data = array();
        if ($ccType = $this->getCcTypeName()) {
            $data[Mage::helper('payment')->__('Credit Card Type')] = $ccType;
        }
        if ($this->getInfo()->getCcLast4()) {
            $data[Mage::helper('payment')->__('Credit Card Number')] = sprintf('xxxx-%s', $this->getInfo()->getCcLast4());
        }
        if (!$this->getIsSecureMode()) {
            if ($ccSsIssue = $this->getInfo()->getCcSsIssue()) {
                $data[Mage::helper('payment')->__('Switch/Solo/Maestro Issue Number')] = $ccSsIssue;
            }
            $year = $this->getInfo()->getCcSsStartYear();
            $month = $this->getInfo()->getCcSsStartMonth();
            if ($year && $month) {
                $data[Mage::helper('payment')->__('Switch/Solo/Maestro Start Date')] =  $this->_formatCardDate($year, $month);
            }
        }
        return $transport->setData(array_merge($data, $transport->getData()));
    }
	
    /**
     * Enter description here...
     *
     * @return string
     */
    public function getMailingAddress()
    {
        if (is_null($this->_mailingAddress)) {
            $this->_convertAdditionalData();
        }
        return $this->_mailingAddress;
    }

    /**
     * Enter description here...
     *
     * @return Mage_Payment_Block_Info_Cashmonew
     */
    protected function _convertAdditionalData()
    {
        $details = false;
        try {
            $details = Mage::helper('core/unserializeArray')
                ->unserialize($this->getInfo()->getAdditionalData());
        } catch (Exception $e) {
            Mage::logException($e);
        }
        if (is_array($details)) {
            $this->_payableTo = isset($details['payable_to']) ? (string) $details['payable_to'] : '';
            $this->_mailingAddress = isset($details['mailing_address']) ? (string) $details['mailing_address'] : '';
        } else {
            $this->_payableTo = '';
            $this->_mailingAddress = '';
        }
        return $this;
    }

    public function toPdf()
    {
        $this->setTemplate('payment/info/pdf/Cashmonew.phtml');
        return $this->toHtml();
    }

}

阻止-表单

<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category    Mage
 * @package     Mage_Payment
 * @copyright  Copyright (c) 2006-2017 X.commerce, Inc. and affiliates (http://www.magento.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */


class Mage_Payment_Block_Form_Cashmonew extends Mage_Payment_Block_Form
{

    protected function _construct()
    {
        parent::_construct();
        $this->setTemplate('payment/form/Cashmonew.phtml');
    }

}
 /**
     * Retrieve availables credit card types
     *
     * @return array
     */
    public function getCcAvailableTypes()
    {
        $types = $this->_getConfig()->getCcTypes();
        if ($method = $this->getMethod()) {
            $availableTypes = $method->getConfigData('cctypes');
            if ($availableTypes) {
                $availableTypes = explode(',', $availableTypes);
                foreach ($types as $code=>$name) {
                    if (!in_array($code, $availableTypes)) {
                        unset($types[$code]);
                    }
                }
            }
        }
        return $types;
    }

等-配置

<?xml version="1.0"?>
<!--
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category    Mage
 * @package     Mage_Payment
 * @copyright   Copyright (c) 2006-2017 X.commerce, Inc. and affiliates (http://www.magento.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
-->
<config>
    <modules>
        <Mage_Payment>
            <version>1.6.0.0</version>
        </Mage_Payment>
    </modules>
    <global>
        <models>
            <payment>
                <class>Mage_Payment_Model</class>
            </payment>
        </models>
        <resources>
            <payment_setup>
                <setup>
                    <module>Mage_Payment</module>
                </setup>
            </payment_setup>
        </resources>
        <blocks>
            <payment>
                <class>Mage_Payment_Block</class>
            </payment>
        </blocks>
		<payment>
            <checkmonew>
                <types>
                    <AE>
                        <code>AE</code>
                        <name>American Express</name>
                        <order>0</order>
                    </AE>
                    <VI>
                        <code>VI</code>
                        <name>Visa</name>
                        <order>10</order>
                    </VI>
                    <MC>
                        <code>MC</code>
                        <name>MasterCard</name>
                        <order>20</order>
                    </MC>
                    <DI>
                        <code>DI</code>
                        <name>Discover</name>
                        <order>30</order>
                    </DI>
                    <SM>
                        <code>SM</code>
                        <name>Maestro/Switch</name>
                        <order>40</order>
                    </SM>
                    <SO>
                        <code>SO</code>
                        <name>Solo</name>
                        <order>45</order>
                    </SO>
                    <JCB>
                        <code>JCB</code>
                        <name>JCB</name>
                        <order>50</order>
                    </JCB>
                    <OT>
                        <code>OT</code>
                        <name>Other</name>
                        <order>1000</order>
                    </OT>
                </types>
            </checkmonew>
            <groups>
                <offline>Offline Payment Methods</offline>
            </groups>
        </payment>
        <payment>
            <cc>
                <types>
                    <AE>
                        <code>AE</code>
                        <name>American Express</name>
                        <order>0</order>
                    </AE>
                    <VI>
                        <code>VI</code>
                        <name>Visa</name>
                        <order>10</order>
                    </VI>
                    <MC>
                        <code>MC</code>
                        <name>MasterCard</name>
                        <order>20</order>
                    </MC>
                    <DI>
                        <code>DI</code>
                        <name>Discover</name>
                        <order>30</order>
                    </DI>
                    <SM>
                        <code>SM</code>
                        <name>Maestro/Switch</name>
                        <order>40</order>
                    </SM>
                    <SO>
                        <code>SO</code>
                        <name>Solo</name>
                        <order>45</order>
                    </SO>
                    <JCB>
                        <code>JCB</code>
                        <name>JCB</name>
                        <order>50</order>
                    </JCB>
                    <OT>
                        <code>OT</code>
                        <name>Other</name>
                        <order>1000</order>
                    </OT>
                </types>
            </cc>
            <groups>
                <offline>Offline Payment Methods</offline>
            </groups>
        </payment>
        <events>
            <sales_order_save_before>
                <observers>
                    <payment_sales_order_save_before>
                        <class>payment/observer</class>
                        <method>salesOrderBeforeSave</method>
                    </payment_sales_order_save_before>
                </observers>
            </sales_order_save_before>
            <sales_order_payment_save_before>
                <observers>
                    <payment_before_save>
                        <class>payment/observer</class>
                        <method>beforeOrderPaymentSave</method>
                    </payment_before_save>
                </observers>
            </sales_order_payment_save_before>
            <sales_order_status_unassign_before>
                <observers>
                    <payment_order_status_unassign_before>
                        <class>payment/observer</class>
                        <method>beforeSalesOrderStatusUnassign</method>
                    </payment_order_status_unassign_before>
                </observers>
            </sales_order_status_unassign_before>
        </events>
    </global>
    <frontend>
        <translate>
            <modules>
                <Mage_Payment>
                    <files>
                        <default>Mage_Payment.csv</default>
                    </files>
                </Mage_Payment>
            </modules>
        </translate>
        <events>
            <catalog_product_type_prepare_full_options>
                <observers>
                    <payment_recurring_profile_prepare_options>
                        <class>payment/observer</class>
                        <method>prepareProductRecurringProfileOptions</method>
                    </payment_recurring_profile_prepare_options>
                </observers>
            </catalog_product_type_prepare_full_options>
        </events>
        <layout>
            <updates>
                <payment module="Mage_Payment">
                    <file>payment.xml</file>
                </payment>
            </updates>
        </layout>
    </frontend>
    <adminhtml>
        <translate>
            <modules>
                <Mage_Payment>
                    <files>
                        <default>Mage_Payment.csv</default>
                    </files>
                </Mage_Payment>
            </modules>
        </translate>
    </adminhtml>
    <default>
        <payment>
            <ccsave>
                <active>1</active>
                <cctypes>AE,VI,MC,DI</cctypes>
                <model>payment/method_ccsave</model>
                <order_status>pending</order_status>
                <title>Credit Card (saved)</title>
                <allowspecific>0</allowspecific>
                <group>offline</group>
            </ccsave>
            <checkmo>
                <active>1</active>
                <model>payment/method_checkmo</model>
                <order_status>pending</order_status>
                <title>Check / Money order</title>
                <allowspecific>0</allowspecific>
                <group>offline</group>
            </checkmo>
			 <checkmonew>
                <active>1</active>
				<cctypes>AE,VI,MC,DI</cctypes>
                <model>payment/method_checkmonew</model>
                <order_status>pending</order_status>
                <title>Card POS</title>
                <allowspecific>0</allowspecific>
                <group>offline</group>
            </checkmonew>
            <free>
                <active>1</active>
                <model>payment/method_free</model>
                <order_status>pending</order_status>
                <title>No Payment Information Required</title>
                <allowspecific>0</allowspecific>
                <sort_order>1</sort_order>
                <group>offline</group>
            </free>
            <purchaseorder>
                <active>0</active>
                <model>payment/method_purchaseorder</model>
                <order_status>pending</order_status>
                <title>Purchase Order</title>
                <allowspecific>0</allowspecific>
                <group>offline</group>
            </purchaseorder>
            <banktransfer>
                <active>0</active>
                <model>payment/method_banktransfer</model>
                <order_status>pending</order_status>
                <title>Bank Transfer Payment</title>
                <allowspecific>0</allowspecific>
                <group>offline</group>
            </banktransfer>
            <cashondelivery>
                <active>0</active>
                <model>payment/method_cashondelivery</model>
                <order_status>pending</order_status>
                <title>Cash On Delivery</title>
                <allowspecific>0</allowspecific>
                <group>offline</group>
            </cashondelivery>
        </payment>
    </default>
</config>

0 个答案:

没有答案