How To Add Custom Notice On Billing & Shipping Address Phone No Field In Magento 2

Hello Everyone,

In this blog, we will learn about how to Add Custom Notice on Billing and Shipping Address Phone No Field in Magento 2.

Getting Phone No during Order Placement is very important for further communication.

Without wasting your time, let us guide you straight away. Follow the easy step given below to Add Custom Notice on Billing and Shipping Address Phone No Field in Magento 2.

STEPS FOR ADD CUSTOM NOTICE ON BILLING AND SHIPPING ADDRESS PHONE NO FIELD IN MAGENTO 2

Step 1: Create di.xml file

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

<?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\LayoutProcessor"/>

     </type>

</config>

Step 2: Create LayoutProcessor.php file

app/code/Vendor/Extension/Model/Checkout/LayoutProcessor.php

<?php

namespace Vendor\Extension\Model\Checkout;

class LayoutProcessor

{

    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');

        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');                

            } 

        }   

        return $jsLayout;

    }

}

Step 3: Finally run the below commands

$ php bin/magento cache:clean

$ php bin/magento cache:flush

Step 4: Output:

Final Thoughts:

So this was the easiest way which we have told you in this blog. This is how you can Add Custom Notice on Billing and Shipping Address Phone No Field in Magento 2. Hope you liked the blog.

So quickly go to the comment box and tell me how you like this blog?

Stay tuned with us on our site to get new updates of Magento.

Thanks for reading and visiting our site.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

How To Add Custom Notice On Billing & Shipping Address Phone No Field In Magento 2

How To Add Custom Notice On Billing & Shipping Address Phone No Field In Magento 2

How To Add Custom Notice On Billing & Shipping Address Phone No Field In Magento 2

How To Add Custom Notice On Billing & Shipping Address Phone No Field In Magento 2

Leave a Reply

Your email address will not be published. Required fields are marked *