Add custom field to onepage checkout in magento?

Disclaimer: I have not touched Magento for 6 months. Now this is said, if you look in the app/code/core/Mage/Sales/sql/sales_setup/ directory you will find examples of how to modify order tables. For instance here is the content of app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.

9.12-0. 9.13. Php (without header comments).

Up vote 1 down vote favorite share g+ share fb share tw.

I'm trying to add custom fields to magento checkout onepage. I followed an example that doesn't work in 1.4.1 because of the move to a flat order table(I think) inchoo.net/ecommerce/magento/adding-a-ne... I can see my custom tab in checkout page with my custom fields but I can't save the fields to the database. How do I add columns to the quote and order tables?

Should this go to Mymod/sql/mymod_setup/mysql4-install-0.1.0. Php or somewhere else? How do I save the field to the db?

Do I need to save it to the quote first? Do I use observer or something else? Do I need to have element in my module's config.

Xml? magentocommerce.com/boards/viewthread/19... Thanks magento checkout link|improve this question asked Aug 21 '10 at 13:01pablo405721 58% accept rate.

Disclaimer: I have not touched Magento for 6 months. Now this is said, if you look in the app/code/core/Mage/Sales/sql/sales_setup/ directory you will find examples of how to modify order tables. For instance here is the content of app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.

9.12-0. 9.13. Php (without header comments): $installer = $this; /* @var $installer Mage_Sales_Model_Mysql4_Setup */ $installer->addAttribute('quote', 'subtotal', array('type'=>'decimal')); $installer->addAttribute('quote', 'base_subtotal', array('type'=>'decimal')); $installer->addAttribute('quote', 'subtotal_with_discount', array('type'=>'decimal')); $installer->addAttribute('quote', 'base_subtotal_with_discount', array('type'=>'decimal')); $this is initialized from what is found in the app/code/core/Mage/Sales/etc/config.

Xml following the config/global/resources/sales_setup/setup/class look into this class and you'll see it inherits from Mage_Eav_Model_Entity_Setup, the default setup class, and overrides or add some methods (for flat table support for instance). To answer your first point (first question), you can add columns by using the addAttribute() method of this class. And the answer to the second question is yes, but you have to specify in the config.

Xml file of your module that you want to use Mage_Sales_Model_Mysql4_Setup as setup class. This is done by adding the same xml element found in app/code/core/Mage/Sales/etc/config. Xml previously (replace sales_setup with yourmod_setup).

So you dump your database, you check it works by using get_class($this) in your mysql4-install-0.1.0. Php file, and then you restore your db. And you continue writing in your setup file, inspiring yourself from what you see in the files in app/code/core/Mage/Sales/sql/sales_setup and it should be fine!

Now for the second point... I don't know... I hope it'll work automatically! Good luck!

I don't think it works for 1.4.1 because the table changed from EAV to flat. Look at mysql4-upgrade-1.4.0.2-1.4.0.3.php. They use addColumn instead of addAttribute.

– pablo Aug 23 '10 at 1:02 @pablo: did you read my answer? If says some methods where added for flat table support. It is the case of addAttribute() method.

Just have a look to the Mage_Sales_Model_Mysql4_Setup class. – greg0ire Aug 23 '10 at 8:14 I missed the fact that you are suggesting to use the Sales setup module. I'll try it and report my results.

Thanks. – pablo Aug 23 '10 at 10:07 In the same module I need to add attributes to sales profile and create a custom flat table so I'm using: $setup = new Mage_Sales_Model_Mysql4_Setup('sales_setup'); for sales and $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); for profile. Thanks – pablo Aug 23 '10 at 0:34.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions