2

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'.

1 Answer 1

3

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.

2
  • thanks for your answer which is really useful. I have edited my question. Commented Feb 9, 2016 at 11:11
  • You're welcome. You can mark this answer as accepted. This will help others having same question. Commented Feb 7, 2017 at 5:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.