Adding Custom Notices to Billing and Shipping Phone Fields in Magento 2- magento source24


Adding Custom Notices to Billing and Shipping Phone Fields in Magento 2:- 


Adding Custom Notices to Billing and Shipping Phone Fields in Magento 2- magento source24


Hello magento friends in this blog post i'm share with you to How to Add Custom Notice on Billing Address and Shipping Address Phone No Field in magento2. Adding a custom notice to the Billing Address and Shipping Address phone number fields in Magento 2 involves a few steps. You can achieve this by creating a simple module and utilizing layout XML and templates. Here's a general outline of the process:

➤ Create a Module:

In your custom module's directory, create the necessary files and folders. Replace Vendor with your actual vendor name and Module with your module's name.

➤ Create Layout XML:

In your module's view/frontend/layout directory, create a file named checkout_index_index.xml. This file will be used to add your custom notice to the checkout page.

<?xml version="1.0"?>

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

    <body>

        <referenceBlock name="checkout.root">

            <arguments>

                <argument name="jsLayout" xsi:type="array">

                    <item name="components" xsi:type="array">

                        <item name="checkout" xsi:type="array">

                            <item name="children" xsi:type="array">

                                <item name="steps" xsi:type="array">

                                    <item name="children" xsi:type="array">

                                        <item name="billing-step" xsi:type="array">

                                            <item name="children" xsi:type="array">

                                                <item name="billingAddress" xsi:type="array">

                                                    <item name="children" xsi:type="array">

                                                        <item name="billing-address-fieldset" xsi:type="array">

                                                            <item name="children" xsi:type="array">

                                                                <item name="telephone" xsi:type="array">

                                                                    <item name="notice" xsi:type="string">

                                                                        Your custom notice here.

                                                                    </item>

                                                                </item>

                                                            </item>

                                                        </item>

                                                    </item>

                                                </item>

                                            </item>

                                        </item>

                                        <item name="shipping-step" xsi:type="array">

                                            <item name="children" xsi:type="array">

                                                <item name="shippingAddress" xsi:type="array">

                                                    <item name="children" xsi:type="array">

                                                        <item name="shipping-address-fieldset" xsi:type="array">

                                                            <item name="children" xsi:type="array">

                                                                <item name="telephone" xsi:type="array">

                                                                    <item name="notice" xsi:type="string">

                                                                        Your custom notice here.

                                                                    </item>

                                                                </item>

                                                            </item>

                                                        </item>

                                                    </item>

                                                </item>

                                            </item>

                                        </item>

                                    </item>

                                </item>

                            </item>

                        </item>

                    </item>

                </argument>

            </arguments>

        </referenceBlock>

    </body>

</page>


➤Clear Cache:

After creating the layout XML, clear the Magento cache so that the changes take effect:

bin/magento cache:clean

➤ Check Checkout Page:

Visit the checkout page, and you should see your custom notices added to the Billing Address and Shipping Address phone number fields.

In this case Remember that this is a general guideline and might need further adjustment based on your theme and specific requirements. Always ensure you have backups and are following best practices when making modifications to your Magento store.




Deepak Kumar Bind

Success is peace of mind, which is a direct result of self-satisfaction in knowing you made the effort to become the best of which you are capable.

Post a Comment

If you liked this post please do not forget to leave a comment. Thanks

Previous Post Next Post