0

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?

2 Answers 2

0

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.

5
  • Hi @diana-botean I have added the field in the extension attribute, but its not working. Mar 9, 2021 at 10:18
  • ok.. that's strange.
    – Diana
    Mar 9, 2021 at 10:38
  • Can you check this? devdocs.magento.com/guides/v2.4/extension-dev-guide/… i am not sure which authentication type are you using, maybe you need to change permissions or something.
    – Diana
    Mar 9, 2021 at 17:33
  • i couldn't found anything for orders, currently, I have defined the attribute using Magento\Sales\Api\Data\OrderAddressInterface, but it's not working. Mar 10, 2021 at 10:09
  • i still think this is a permission's issue check this devdocs.magento.com/guides/v2.4/get-started/authentication/… and also in 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.
    – Diana
    Mar 10, 2021 at 10:17
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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