I've created a couple of order attributes using the method described here (https://www.yereone.com/blog/magento-2-how-to-add-new-order-attribute/) in order to save some data that is passed into Magento 2 via our legacy application.
Is it possible to pass these values over when creating an order via the API? or is there a better way to achieve the same result? I'm using Magento 2.3 if that has any impact.
Best Answer
First read this below articles:
If you want to add a field them you need to use extension_atttibutes
Extension attribute gives the facility to add a new field to existing API point.
The fields which you have created using https://www.yereone.com/blog/magento-2-how-to-add-new-order-attribute/) to be used as an extension attribute for data
Magento\Sales\Api\Data\OrderInterface
.So, create
etc/extension_attributes.xml
at your module folderSave field to order table
And as you have created the column to an existing order table, So save the create before plugin on
\Magento\Sales\Api\OrderRepositoryInterface::save()
.