I want to add one extra text field in checkout billing form and also save that field data in order so I can show that field data in admin order view and also in order email.
I already tried to add in shipping and it works properly but I want to add in billing.
Please help me.
Best Answer
Please check below code to save custom address attribute in customer,checkout shipping and billing form and also save in order table.
Module Name : Ccc_Checkout
Script to create custom attribute for address and order
app/code/Ccc/Checkout/Setup/UpgradeData.php
app/code/Ccc/Checkout/etc/di.xml
app/code/Ccc/Checkout/etc/events.xml
app/code/Ccc/Checkout/etc/extension_attributes.xml
Create Plugin to display custom attribute in checkout billing and shipping form
app/code/Ccc/Checkout/Plugin/Block/Checkout/LayoutProcessor
To save custom attribute in checkout
app/code/Ccc/Checkout/Plugin/Magento/Quote/Model/ShippingAddressManagement
app/code/Ccc/Checkout/Plugin/Magento/Quote/Model/BillingAddressManagement
app/code/Ccc/Checkout/Ccc/Checkout/Plugin/Magento/Quote/Model/Quote/Address
To set custom attribute in extension attribute
app/code/Ccc/Checkout/view/frontend/requirejs-config.js
app/code/Ccc/Checkout/view/frontend/web/js/action/create-shipping-address-mixin.js
app/code/Ccc/Checkout/view/frontend/web/js/action/set-billing-address-mixin.js
app/code/Ccc/Checkout/view/frontend/web/js/action/set-shipping-information-mixin.js
To save custom attribute in orders
app/code/Ccc/Checkout/Observer/SaveUnitNumberInOrder.php
To display custom attribute in customer account you need to overright customer edit.phtml file from vendor to your theme like below :
app/design/frontend/custom_theme/theme_name/Magento_Customer/templates/address/edit.phtml