3

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.

BlueSun3k1
  • 757
  • 5
  • 21
  • 39

2 Answers2

0

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.

Gaia
  • 2,872
  • 1
  • 41
  • 59
  • Thanks, I went through the link you provided and I had already seen one of them before but got me nowhere. I was able to get some clue as of what I might have to do which I will post ahead. – BlueSun3k1 Aug 08 '12 at 00:01
  • Please read my comment on the other response below. I wasn't able to post it as a response to my own question due to not having enough reputation. – BlueSun3k1 Aug 08 '12 at 00:06
-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.

Kalpesh
  • 5,635
  • 2
  • 23
  • 39
  • Thank you, after reading your post I went thru the DB and took a look at the tables and I was able to come up with something, please read ahead since this box is limited on characters. – BlueSun3k1 Aug 08 '12 at 00:02
  • Great I don't have enough rep to answer my own question. well here it goes. I'm kinda of new at magento and excuse me, I should've mentioned before what I have done. well after reading both responses and reading a bit more around other pages and digging through the DB tables, I was only able to figure that the new columns should be inserted into the following tables. - sales_flat_quote_payment - sales_flat_order_payment - eav_attribute However, I'm not sure if I should be adding values to any other tables. – BlueSun3k1 Aug 08 '12 at 00:05
  • Besides editing the cc.phtml and ccsave.phtml to add the new field input-box, I'm don't know if I should be editing anything else. I will give it a try but somehow it feels too simple in comparison to everything I had to do to add custom fields to the customer registration form. somehow I feel there are some core files that should be overridden under my local folder but it escapes me. I know I had to do it when I added custom customer fields. – BlueSun3k1 Aug 08 '12 at 00:05
  • Ok I've done everything I mentioned above and no crashes or anything but the data is not being saved. – BlueSun3k1 Aug 08 '12 at 01:07
  • customer tables are `eav`, forget about it. Yes, you should have two columns in `sales_flat_quote_payment` and `sales_flat_order_payment`. – Kalpesh Aug 08 '12 at 07:35
  • I figured it out after hours of poking around. I Overrode the following files from Core/Mage to Local/Mage 1. /Payment/Model/Method/Cc.php <= on this file I added ->setCcBankname($data->getCcBankname()) where the other similar values are at the top. 2. /Payment/etc/config.xml and /sales/etc/config.xml <= simply copied from it's original location, left unmodified. 3. /Sales/Model/Entity/Setup.php and Resource/Setup.php <= Added my attribute 'cc_bankname' => array(), where needed. I tested it and the "Bank Name" value was successfully saved to the DB attribute I previously set. – BlueSun3k1 Aug 08 '12 at 15:16
  • the eav_attribute table is indeed customer's table but after going thru the sales_flat tables, I compared all the column values with the values found in eav_attribute and there are two instances of each value under there so for w/e reason, it was needed to add the values with a specific entity_type_id of 8 and 16 respectively. – BlueSun3k1 Aug 08 '12 at 15:21