Last active
January 20, 2019 16:04
-
-
Save veritstudio/dcdd0d6fd3d0850c25f045a897eb625a to your computer and use it in GitHub Desktop.
Modify address fields in Magento 2 checkout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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="rewrite-address" type="VeritStudio\Checkout\Model\Checkout\LayoutProcessorPlugin" sortOrder="20"/> | |
</type> | |
</config> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace VeritStudio\Checkout\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'), | |
'required' => false, | |
'dataScope' => 'shippingAddress.street', | |
'provider' => 'checkoutProvider', | |
'sortOrder' => 70, | |
'type' => 'group', | |
'additionalClasses' => 'street', | |
'children' => [ | |
[ | |
'label' => __('* Street Address'), | |
'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, "max_text_length" => 255], | |
], | |
[ | |
'label' => __('* Street no.'), | |
'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' => true, "min_text_length" => 1, "max_text_length" => 255], | |
], | |
[ | |
'label' => __(''), | |
'component' => 'Magento_Ui/js/form/element/abstract', | |
'config' => [ | |
'customScope' => 'shippingAddress', | |
'template' => 'ui/form/field', | |
'elementTmpl' => 'ui/form/element/input' | |
], | |
'dataScope' => '2', | |
'provider' => 'checkoutProvider', | |
'placeholder' => '(optional)', | |
'additionalClasses' => 'additional', | |
'validation' => ['required-entry' => false, "min_text_length" => 1, "max_text_length" => 255], | |
], | |
[ | |
'label' => __(''), | |
'component' => 'Magento_Ui/js/form/element/abstract', | |
'config' => [ | |
'customScope' => 'shippingAddress', | |
'template' => 'ui/form/field', | |
'elementTmpl' => 'ui/form/element/input' | |
], | |
'dataScope' => '3', | |
'provider' => 'checkoutProvider', | |
'placeholder' => '(optional)', | |
'additionalClasses' => 'additional', | |
'validation' => ['required-entry' => false, "min_text_length" => 1, "max_text_length" => 255], | |
], | |
] | |
]; | |
$jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children'] | |
['payment']['children']['afterMethods']['children']['billing-address-form']['children']['form-fields']['children']['street'] = [ | |
'component' => 'Magento_Ui/js/form/components/group', | |
//'label' => __('Street Address'), | |
'required' => false, | |
'dataScope' => 'shippingAddress.street', | |
'provider' => 'checkoutProvider', | |
'sortOrder' => 70, | |
'type' => 'group', | |
'additionalClasses' => 'street', | |
'children' => [ | |
[ | |
'label' => __('* Street Address'), | |
'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, "max_text_length" => 255], | |
], | |
[ | |
'label' => __('* Street no.'), | |
'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' => true, "min_text_length" => 1, "max_text_length" => 255], | |
], | |
[ | |
'label' => __(''), | |
'component' => 'Magento_Ui/js/form/element/abstract', | |
'config' => [ | |
'customScope' => 'shippingAddress', | |
'template' => 'ui/form/field', | |
'elementTmpl' => 'ui/form/element/input' | |
], | |
'dataScope' => '2', | |
'provider' => 'checkoutProvider', | |
'placeholder' => '(optional)', | |
'additionalClasses' => 'additional', | |
'validation' => ['required-entry' => false, "min_text_length" => 1, "max_text_length" => 255], | |
], | |
[ | |
'label' => __(''), | |
'component' => 'Magento_Ui/js/form/element/abstract', | |
'config' => [ | |
'customScope' => 'shippingAddress', | |
'template' => 'ui/form/field', | |
'elementTmpl' => 'ui/form/element/input' | |
], | |
'dataScope' => '3', | |
'provider' => 'checkoutProvider', | |
'placeholder' => '(optional)', | |
'additionalClasses' => 'additional', | |
'validation' => ['required-entry' => false, "min_text_length" => 1, "max_text_length" => 255], | |
], | |
] | |
]; | |
return $jsLayout; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" ?> | |
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | |
<module name="VeritStudio_Checkout" setup_version="1.0.0"> | |
<sequence> | |
<module name="Magento_Checkout"/> | |
</sequence> | |
</module> | |
</config> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
\Magento\Framework\Component\ComponentRegistrar::register( | |
\Magento\Framework\Component\ComponentRegistrar::MODULE, | |
'VeritStudio_Checkout', | |
__DIR__ | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment