I'm working on one project and i wants some extra fields on cart page under estimate shipping and tax.
- Hide Country field
- Show State as "Province" Text
- Show City as "Canton" as a Dropdown (data will load from database).
- Show "District" custom field as Dropdown (data will load from database)
- Show Postal Code as Dropdown (data will load from database)
i've modified vendor/magento/module-checkout/Block/Cart/LayoutProcessor.php file
Original Code
$elements = [
'city' => [
'visible' => $this->isCityActive(),
'formElement' => 'text',
'label' => __('City'),
'value' => null
],
'country_id' => [
'visible' => true,
'formElement' => 'select',
'label' => __('Country'),
'options' => [],
'value' => null
],
'region_id' => [
'visible' => true,
'formElement' => 'select',
'label' => __('State'),
'options' => [],
'value' => null
],
'postcode' => [
'visible' => true,
'formElement' => 'text',
'label' => __('Postcode'),
'value' => null
]
];
After Modification
$elements = [
'city' => [
'visible' => true,
'formElement' => 'select',
'label' => __('cant贸n'),
'value' => null
],
'country_id' => [
'visible' => true,
'formElement' => 'select',
'label' => __('Country'),
'options' => [],
'value' => null
],
'region_id' => [
'visible' => true,
'formElement' => 'select',
'label' => __('Provincia'),
'options' => [],
'value' => null
],
'postcode' => [
'visible' => true,
'formElement' => 'select',
'label' => __('Postal Code'),
'value' => null
],
'distro' => [
'visible' => true,
'formElement' => 'select',
'label' => __('Distro'),
'value' => null
]
];
this code isn't working I'm facing error
1 exception(s):
Exception #0 (Exception): Notice: Undefined index: sortOrder in /home/samarpan/mage.samarpanherbslife.com/vendor/magento/module-checkout/Block/Checkout/AttributeMerger.php on line 194
if i remove
'distro' => [
'visible' => true,
'formElement' => 'select',
'label' => __('Distro'),
'value' => null
]
then it's working fine but City comes after postcode. so kindly please suggest or help me for
- How to load data from database to city field (Dropdown).
- How to add Custom field(Dropdown) and load data into it from database.
- How to move city above Postcode
- How to create, Manage and best way for Custom Tables, those link with another tables like, Country and State already linked. City Depends on State, District Depends on City, Postal Code Depends on District.
Thank you.