Magento: Add New Field to Credit Card Form

微笑、不失礼 提交于 2019-12-10 19:33:47

问题


I'm trying to modify the credit card form to add some new custom fields named "Bank Name" and "Bank Phone Number" and it seems this cannot be done through the back-end.

I've searched the web and on here but I haven't been able to find anything in reference on how to add a new custom field to the credit card form. I would think it's almost the same as adding a new field to the customer registration form but I have no clue what to do database wise.

If anyone has anything I can use to work on this, I'd greatly appreciate it.


回答1:


No, Magento admin panel will not add custom columns for you. You need to do it yourself.

First, you need to edit the .phtml file to include these two fields to show up in frontend.

Second, you need to add two new columns (with same name as your fields, explained later) in relevant DB table (i guess sales_flat_order_payment). But that will affect for all payment methods, so define it something like VARCHAR(255) NULL.

Third, when Magento saves the CC info, you need to check if it is saving whole data array, then your field's name posted will match your table field and get inserted automatically. Else you need to edit it.

Also, next time please post some code, atleast something you have tried.




回答2:


You should start by informing which version of Magento you are using and which methods you have already tried.

Without knowing that it is hard to help you, but you might want to try this possible solution, this one, or even one of these modules: Checkout Fields Manager or ADDITIONAL CHECKOUT ATTRIBUTES. If none of the above work, try this search.



来源:https://stackoverflow.com/questions/11854903/magento-add-new-field-to-credit-card-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!