I have successfully placed order by creating cart and finally calling rest api /rest//V1/guest-carts/{cart-id}/order to place the order. Now I am trying to add an additional attribute custom_attribute to be displayed on orders table page of admin dashboard but am unable to figure out the way around.
I have tried to extend the magento functionality using following link but somehow cannot set custom attribute via rest api
https://www.yereone.com/blog/magento-2-how-to-add-new-order-attribute/
1 Answer 1
You can do that with help of extension attributes , here is magento documentation how to add an extension attribute https://devdocs.magento.com/guides/v2.4/extension-dev-guide/extension_attributes/adding-attributes.html
There are also some stack questions that you can refer to
Add extension attribute to Order
and some good articles https://www.rakeshjesadiya.com/extension-attribute-in-order-data-magento-2/
-
I am unable to get this line working: $orderComment = $order->getData(self::FIELD_NAME); as given in the article I am calling the api : /rest//V1/guest-carts/{cart-id}/order and passing 'order_comment' in request but somehow unable to access it here.Praveen Soni– Praveen Soni2020年11月07日 06:39:46 +00:00Commented Nov 7, 2020 at 6:39
-
Share in question , the code you have triedVishwas Bhatnagar– Vishwas Bhatnagar2020年11月08日 08:19:35 +00:00Commented Nov 8, 2020 at 8:19