0

On product page I've a custom text field and I want to save it to order's comment section, if it is filled and order placed for that user.

I can either use sales_order_status_history_save_after or sales_order_place_after event to add comment to an order. How I can manage the session of the entered text ? Will it be fine to set session of the entered text in my controller using Mage::getSingleton('core/session')->setOrderComment($text); and observe it in sales_order_status_history_save_after and update order?

All I wanted to make sure is this comment goes for the particular product and customer who has entered this text. Can I set it on quote creation level ?

amitshree
  • 7,006
  • 12
  • 63
  • 116

1 Answers1

1

To save info in session

Use an observer for product add to cart(eg checkout_cart_product_add_after), then in your observer save the information to session.

Maybe a better way to do this would be to add the comment to the product custom option

To save order comment

Using sales_order_place_before event. Then in your observer check if session exist, then append the comment using addStatusHistoryComment.

MagePal Extensions
  • 13,911
  • 2
  • 33
  • 52
  • By adding the comment to product custom option, do you mean I need to create that attribute in product's custom option section? – amitshree Sep 24 '15 at 05:13
  • No. It will look something like this http://i.stack.imgur.com/SfhBI.png... Take a look at http://magento.stackexchange.com/questions/1327/creating-custom-option-and-prize-to-just-added-product-to-cart-using-observer – MagePal Extensions Sep 24 '15 at 12:26