Categories
CMS Magento Mastering Development

Adding label to text field

How can I add a label to the custom field in the checkout page? I can’t seem to find a source for that. Assuming code is like what is in the Mageplaza sample <?php $customAttributeCode = ‘custom_field’; $customField = [ ‘component’ => ‘Magento_Ui/js/form/element/abstract’, ‘config’ => [ // customScope is used to group elements within a […]

Categories
CMS Magento Mastering Development

Add TEXTAREA to LayoutProcessor

Hi how do I add a TextArea in my Checkout Page? right now all I can find are ways to add a input field but is there a way to add a text area and not a text field? I’m planning to add a comment field to my checkout but I can’t find any solution. […]

Categories
CMS Magento Mastering Development

How to set region value in checkout page?

I am following this guide to build a zipcode lookup implementation. I try to populate region, city and street data based on zipcode. this.region().value(regionValue); this.city().value(cityValue); this.street().elems()[0].set(‘value’, streetValue); With code above, city and street fields successfully changed when I type zipcode but no for region field. Is there any different implementation for region field? Here is […]

Categories
CMS Magento Mastering Development

Magento 2 custom checkout select field shippingAdditional add or remove require-entry upon selected shipping method

If Free Shipping Method is selected change validation E.G:’validation’ => [‘required-entry’ => false], … ‘custom_field’ => [ ‘component’ => ‘Vendor_Module/js/custom-field-component’, ‘config’ => [ ‘customScope’ => ‘shippingAddress.custom_attributes’, ‘template’ => ‘ui/form/field’, ‘elementTmpl’ => ‘Vendor_Module/fields/select’, ‘options’ => $this->getOptions(), ‘id’ => ‘custom_field’ ], ‘dataScope’ => ‘custom_scope.custom_field’, ‘label’ => ‘Select Option’, ‘provider’ => ‘checkoutProvider’, ‘visible’ => true, ‘validation’ => [‘required-entry’ […]

Categories
CMS Magento Mastering Development

Magento 2 custom checkout select field shippingAdditional add or remove require-entry upon selected shipping method

If Free Shipping Method is selected change validation E.G:’validation’ => [‘required-entry’ => false], … ‘custom_field’ => [ ‘component’ => ‘Vendor_Module/js/custom-field-component’, ‘config’ => [ ‘customScope’ => ‘shippingAddress.custom_attributes’, ‘template’ => ‘ui/form/field’, ‘elementTmpl’ => ‘Vendor_Module/fields/select’, ‘options’ => $this->getOptions(), ‘id’ => ‘custom_field’ ], ‘dataScope’ => ‘custom_scope.custom_field’, ‘label’ => ‘Select Option’, ‘provider’ => ‘checkoutProvider’, ‘visible’ => true, ‘validation’ => [‘required-entry’ […]

Categories
CMS Magento Mastering Development

Magento 2 custom checkout select field shippingAdditional add or remove require-entry upon selected shipping method

If Free Shipping Method is selected change validation E.G:’validation’ => [‘required-entry’ => false], … ‘custom_field’ => [ ‘component’ => ‘Vendor_Module/js/custom-field-component’, ‘config’ => [ ‘customScope’ => ‘shippingAddress.custom_attributes’, ‘template’ => ‘ui/form/field’, ‘elementTmpl’ => ‘Vendor_Module/fields/select’, ‘options’ => $this->getOptions(), ‘id’ => ‘custom_field’ ], ‘dataScope’ => ‘custom_scope.custom_field’, ‘label’ => ‘Select Option’, ‘provider’ => ‘checkoutProvider’, ‘visible’ => true, ‘validation’ => [‘required-entry’ […]

Categories
CMS Magento Mastering Development

How to change value of custom Label and field on change of postcode?

I have created a custom module and created Block to add custom hidden fields on checkout page. 1. Vendor/Module/Plugin/Checkout/Block/LayoutProcessor ‘delivery_comment’ => [ ‘component’ => ‘Magento_Ui/js/form/element/abstract’, ‘config’ => [ ‘customScope’ => ‘delivery_date’, ‘template’ => ‘ui/form/field’, ‘elementTmpl’ => ‘ui/form/element/hidden’, ‘options’ => [], ‘id’ => ‘delivery_comment’ ], ‘dataScope’ => ‘delivery_date.delivery_comment’, ‘label’ => ‘Expected Delivery date will be ‘.$deliveryDate, […]

Categories
CMS Magento Mastering Development

Checkout address custom attributes don’t get rendered in address information components

I have to add a new customer address attribute apellido2, this field is a second lastname and must be present in both shipping and billing address. So i after reading a few posts, i started with my custom module: app/code/Vendor/Module/etc/extension_attributes.xml <?xml version=”1.0″?> <config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:Api/etc/extension_attributes.xsd”> <extension_attributes for=”Magento\Customer\Api\Data\AddressInterface”> <attribute code=”apellido2″ type=”string” /> </extension_attributes> </config> app/code/Vendor/Module/etc/di.xml <?xml […]

Categories
CMS Magento Mastering Development

Date Format by UI component shows wrong date of birth

I have one new customer attribute for that I have added it in checkout page by extending LayoutProcessor’s public function afterProcess(\Magento\Checkout\Block\Checkout\LayoutProcessor $subject, array $jsLayout){ $customField1 = [ ‘component’ => ‘Magento_Ui/js/form/element/abstract’, ‘config’ => [ // customScope is used to group elements within a single form (e.g. they can be validated separately) ‘customScope’ => ‘shippingAddress.custom_attributes’, ‘customEntry’ => […]

Categories
CMS Magento Mastering Development

Address Validation in checkout page in Magento 2

I want to validate street address line 1 & 2 with maximum 40 character and without special character. I am using below code for this but it’s not working for me. etc/di.xml <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=”add-street-field” type=”X\Y\Model\Checkout\LayoutProcessorPlugin” sortOrder=”1″/> </type> </config> Model\Checkout\LayoutProcessorPlugin.php public function afterProcess( \Magento\Checkout\Block\Checkout\LayoutProcessor $subject, array $jsLayout ) { $jsLayout[‘components’][‘checkout’][‘children’][‘steps’][‘children’][‘shipping-step’][‘children’] [‘billingAddress’][‘children’][‘shipping-address-fieldset’][‘children’][‘street’] […]