Magento has a feature to define between 1 and 4 fields, how much do you want to use in the street field?
I’ve activated 2 fields and would like to add a label for 1 field. I have done this on the checkout shipping address page which you can see in the image below:
I just do rewriting checkout layout on di.xml :
1 2 3 |
<type name="Magento\Checkout\Block\Checkout\LayoutProcessor"> <plugin name="rewrite-street" type="Vendor\ModuelName\Model\Checkout\LayoutProcessorPlugin"/> </type> |
And create a new LayoutProcessorPlugin.php file at Vendor\ModuelName\Model\Checkout\LayoutProcessorPlugin.php path
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
<?php namespace Vendor\ModuleName\Model\Checkout; class LayoutProcessorPlugin { /** * @param \Magento\Checkout\Block\Checkout\LayoutProcessor $subject * @param array $jsLayout * @return array */ public function afterProcess( \Magento\Checkout\Block\Checkout\LayoutProcessor $subject, array $jsLayout ) { $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children'] ['shippingAddress']['children']['shipping-address-fieldset']['children']['street'] = [ 'component' => 'Magento_Ui/js/form/components/group', 'label' => __('Street Address'), // You can change main label from here 'required' => true, //turn false if you can removed main label 'dataScope' => 'shippingAddress.street', 'provider' => 'checkoutProvider', 'sortOrder' => 30, // You can set short order of street fields from other checkout fields 'type' => 'group', 'additionalClasses' => 'street', 'children' => [ [ 'label' => __('Label 1'), // Here I can set Label "Adresa" as per above image 'component' => 'Magento_Ui/js/form/element/abstract', 'config' => [ 'customScope' => 'shippingAddress', 'template' => 'ui/form/field', 'elementTmpl' => 'ui/form/element/input' ], 'dataScope' => '0', 'provider' => 'checkoutProvider', 'validation' => ['required-entry' => true, "min_text_length" => 1], // You can also set "max_text_length"=> 255 in validation ], [ 'label' => __('Label 2'), 'component' => 'Magento_Ui/js/form/element/abstract', 'config' => [ 'customScope' => 'shippingAddress', 'template' => 'ui/form/field', 'elementTmpl' => 'ui/form/element/input' ], 'dataScope' => '1', 'provider' => 'checkoutProvider', 'validation' => ['required-entry' => false, "min_text_length" => 1], ], ] ]; return $jsLayout; } } |
You can do this in any existing module.
[crayon-63d3d74f260d6142684896/] Using above fucntion Images can be imported directly from...
Override view block using di.xml and add the below code...
You can check a list of called layout XML for...
Follow the below steps to install and set up PWA...
If you want to remove all leading zero's from order,...
Let our Magento expert connect to discuss your requirement.
We offer Magento
certified developers.
Our Magento clientele
is 500+.
We sign NDA for the
security of your projects.
We’ve performed 100+
Magento migration projects.
Free quotation
on your project.
Three months warranty on
code developed by us.