I have added a custom field on checkout in shipping address section using below code.
etc/frontend/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Checkout\Block\Checkout\LayoutProcessor">
<plugin name="ProcessAddressConfiguration" type="Vendor\Module\Block\Checkout\PassportProcessor"/>
</type>
</config>
Block/Checkout/PassportProcessor.php
<?php
namespace Vendor\Module\Block\Checkout;
class PassportProcessor
{
public function afterProcess(\Magento\Checkout\Block\Checkout\LayoutProcessor $processor, $jsLayout){
$passport_no = 'passport_no';
$newField = [
'component' => 'Magento_Ui/js/form/element/abstract',
'config' => [
'customScope' => 'shippingAddress.custom_attributes',
'customEntry' => null,
'template' => 'ui/form/field',
'elementTmpl' => 'ui/form/element/input',
'tooltip' => [
'description' => 'description'
]
],
'dataScope' => 'shippingAddress.custom_attributes.' . $passport_no,
'label' => 'Passport Number',
'provider' => 'checkoutProvider',
'sortOrder' => 0,
'validation' => [
'required-entry' => true
],
'options' => [],
'filterBy' => null,
'customEntry' => null,
'visible' => true
];
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']['shippingAddress']['children']['shipping-address-fieldset']['children'][$passport_no] = $newField;
return $jsLayout;
}
}
Questions:
- In which tables I should save it so that when I pull the order,
passport_no
should be available in shipping address section of that order? - How I can save
passport_no
in those tables from here?
I went through multiple posts but I do not see a complete list of steps which should be taken to achieve it.