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.
If you want get query string params in controller file,...
Create di.xml and add the below code Magemonkey/Redirect/etc/frontend/di.xml [crayon-628767ba008f7760248368/] Create...
You can try below code to change local date to...
Step 1: First you need to add registration.php file in...
Step1 : Override message.js in current theme file on the...