I want to create a field "add gift to this order" similar to "Order History->Order Comments" on create order page of admin.
I have tried this : https://stackoverflow.com/questions/12936470/adding-a-new-attribute-to-order-in-magento and some other tutorials.
EDITED :
I have put the following code in /app/design/adminhtml/default/default/template/sales/order/create/comment.phtml
<textarea style="width:98%; height:8em;" id="order-freegift" name="order[freegift][freegift_note]" rows="2" cols="15"><?php echo $this->getFreegiftNote() ?></textarea>
and created a function in core file which is not recommended : /app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Comment.php
I have modified this file only for testing purpose.
public function getFreegiftNote()
{
return $this->escapeHtml($this->getQuote()->getCustomerNote());
}
Then I created an order with free gift 'xyz' from admin.
How can I get this gift on the Order View Page?
In which table this custom attribute value is saved? For this I have looked into all tables of 'sales_order' but not found the gift 'xyz'.
Best Answer
First thing to understand is the create order page in admin comes from the layout
adminhtml_sales_order_create_index
All the order form fields comes in this layout only.Now just add this layout in your adminhtml layout file & add your custom attribute field in the phtml associated with
adminhtml_sales_order_create_index
layout.That's it.