How to add a custom attribute to the shipping address in Magento 2?

Adding custom fields to a shipping address in Magento 2 is a technically challenging task that requires you to have coding knowledge and programming skills. This process can be facilitated with the Custom Checkout Fields extension, which allows you to make changes to the shipping address without high technical skills.

How to add a custom attribute to the shipping address?

Step 1. Navigate to Sales > Manage Order Attributes to start the Magento 2 add a custom field to the billing address process.

Step 2. Click the Add New Order Attribute button.

Step 3. The Attribute Configuration process is divided into 3 sections. The first is the General Configuration:

general attribute configuration

Step 4. In the Default Label section, you need to write the attribute to be displayed on the frontend page.

Step 5. Then you need to write the Attribute Code for internal needs.

Step 6. The next section is to choose the Store View for which the attribute will be shown.

Step 7. After that, choose the Customer Groups to which the attribute will be shown.

Step 8. Specify the Frontend Input Type in the dropdown. 

Step 9. Now choose the needed option in the Values Required dropdown. If you choose Yes, users will have to fulfill this field during registration.

Step 10. The second section is Attribute Type Settings:

attribute type settings

Step 11. Choose whether you want your attribute to be Visible on frontend and to be Visible on backend.

Step 12. SetYes on the Input Validation option to make the filled information checked for being valid before submission.

Step 13. After that, specify the Maximum and Minimum Text Length for the attribute.

Step 14. Now you see the Input/Output Filter dropdown. Choose the appropriate option:

  • the Strip HTML Tags option excludes the code injections
  • the Escape HTML Entities option is to screen the code injection (both for frontend and backend).

Step 15. And the third section is Attribute Display Settings:

attribute display

Step 16. Choose the Shipping Address option in the Position at Checkout Step dropdown to add the attribute to the Shipping Address page.

Step 17. Fulfill Sort Order section in numeric. It is used in the front-end to sort attributes.

Step 18. In the next dropdown, choose whether to Save Entered Value For Future Checkout or no. And do the same with the Show on Admin Grids option.

Step 19. Choose Yes in the Include Into HTML Print-out dropdown to make order attributes included in the document that a customer prints in his account.

Step 20. Set Yes in the Include Into PDF Documents dropdown to make your attribute included in pdf docs. And do the same with the Include Into Transactional Emails option.

Step 21. Save your attribute.

How to add a custom attribute to the shipping address? 

Step 1. To add a custom field to the shipping address in Magento 2 navigate to Sales > Manage Order Attributes.

Step 2. Click the Add New Order Attribute button.

Step 3. The Attribute Configuration process is divided into 3 sections. The first is the General Configuration:

Step 4. In the Default Label section, you need to write the attribute to be displayed on the frontend page.

Step 5. Then you need to write the Attribute Code for internal needs.

Step 6. The next section is to choose the Store View for which the attribute will be shown.

Step 7. The next step to add a custom attribute to the shipping address in Magento 2 is to choose the Customer Groups to which the attribute will be shown.

How can we help you?

Didn’t you find the answer to your question? We are always happy to help you out.

© 2009-2021 Amasty. All Rights Reserved.