I want to add Custom Address Attribute field in order api,
The field data is saved in sales_order_address table, but it dosen't show in order api
Anyone have idea how to add it to order api?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI want to add Custom Address Attribute field in order api,
The field data is saved in sales_order_address table, but it dosen't show in order api
Anyone have idea how to add it to order api?
The custom field must be added as an extension attribute for Magento\Sales\Api\Data\OrderAddressInterface
.
This will make it visible (if populated) inside the 'billing_address -> extension_attributes' and/ or 'extension_attributes -> shipping_assignments -> shipping -> address -> extension_attributes' areas of the response of the /rest/V1/orders/{id}
endpoint.
vendor/magento/module-sales/etc/webapi.xml
the "/V1/orders/:id" clearly states that you need admin or integration permissions to see the data. if you are using an admin user token then i would double check that the admin has permissions over the order view actions.
Create extension_attribute to add customer address to your order
See how to add at: https://www.mageplaza.com/devdocs/add-extension-attributes-to-entity-magento-2.html