How to Add Custom Notice on Billing Address and Shipping Address Phone No Field in Magento2

 1 Steps to Add Custom Notice on Billing Address and Shipping Address Phone No Field in Magento 2:

2 Conclusion:

Steps to Add Custom Notice on Billing Address and Shipping Address Phone No Field in Magento 2:

Step 1: Go to the below file path


app\code\Vendor\Extension\etc\di.xml


Now add the code as given below




<?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-checkout-fields" type="Vendor\Extension\Model\Checkout\LayoutProcessorplugin" sortOrder="10"/>

     </type>

</config>



Step 2: Now move to the following file path


app\code\Vendor\Extension\Model\Checkout\LayoutProcessorplugin.php


Then add the code as follows


<?php

namespace Vendor\Extension\Model\Checkout;

 

class LayoutProcessorplugin

{

    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']['telephone']['notice'] = __('Enter Number With Country code & without any sign. e.g:-(91xxxxxxx09)');

       

        if (isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']

            ['payment']['children']['payments-list']['children'])) 

        {

            foreach ($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children'] as $key => $payment) 

            {                

                $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children'][$key]['children']['form-fields']['children']['telephone']['notice'] = __('Enter Number With Country code & without any sign. e.g:-(91xxxxxxx09)');                

            } 

 

        }   

        return $jsLayout;

    }

}

Step 3: After that, run the below commands


php bin/magento setup:di:compile

php bin/magento cache:flush

Comments

Popular posts from this blog

Add Admin User name and Action name in Order Comment Section through Action Performed from Sales Order Grid in Magento 2

How to Update Product Stock Programmatically in Magento 2

How to Set and Get Cookie in Magento 2