werd
werd

Reputation: 646

Magento save custom sales_flat_order attribute when saving order

I am using Magento 1.7.0.2 I have created a custom attribute in sales_flat_order table using this installer code:

$setup = new Mage_Sales_Model_Mysql4_Setup('core_setup');
$setup->addAttribute('order', 'my_custom_attribute', array(
  'type'    => 'varchar'
));

I have made some changes to IWD onepagecheckout module to show my custom attribute input field but I dont know how to force to save this attribute value in sales_flat_order?

How to solve this?(I will appreciate real example for this couse related question didnt gave me the answer)

P.S. Please note that I am not changing any core files so solution for this could use my custom module I already have.

Best regards!

Upvotes: 0

Views: 1644

Answers (1)

Xman Classical
Xman Classical

Reputation: 5406

From another answer: You can listen to the checkout_type_onepage_save_order_after event or the checkout_onepage_controller_success_action if you use the default One Page Checkout checkout. The former is called when an order is created and saved, the latter when a order is succesfully placed.

You can find a tutorial about how to use events here: http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/customizing_magento_using_event-observer_method.

Hope that helps :-)

Upvotes: 1

Related Questions