2

I'd like to add a comment to some checkout fields on Magento 2.1.10 without using tooltips (that I need to remove). So I edited the checkout_index_index.xml and in shipping-address-fieldset section I've added the following:

    <item name="shipping-address-fieldset" xsi:type="array">
         <item name="children" xsi:type="array">
            <item name="telephone" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="tooltip" xsi:type="boolean">false</item>
                </item>
            </item>
            <item name="company" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="notice" xsi:type="string">My notice</item>
                </item>
            </item>
        </item>
    </item>

Tooltip is hidden but no notice appears...

Any help would be very appreciated...

3 Answers 3

0

To do this, you can add a custom template for a specific form field. This is perfectly explained in the Magento 2 devdocs. Take a look here: http://devdocs.magento.com/guides/v2.2/howdoi/checkout/checkout_edit_form.html

0
3

1.Create a di.xml under 'etc' directory of your any custom module

<?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="Namespace\Module\Model\Checkout\LayoutProcessorPlugin" sortOrder="10"/>
    </type>
</config>

2.Create a file called LayoutProcessorPlugin.php file under 'Namespace/Module/Model/Checkout'.

<?php
namespace Namespace\Module\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']['firstname']['notice'] = __('Please enter first name here'); 
        $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']
            ['children']['shippingAddress']['children']['shipping-address-fieldset']['children']['lastname']['notice'] = __('Please enter last name here'); 
        return $jsLayout;
    }
}

Note: here i add comment below first and last name you can do for others too.Please accept and vote if use full to you this will help others too.enter image description here

0

Also it's possible to add a notice in the checkout field by layout.

In: app/design/forntend/Vendor/theme/Magento_Checkout/checkout_index_index.xml

<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="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="country_id" xsi:type="array">
                                                                <item name="config" xsi:type="array">
                                                                    <item name="notice" xsi:type="string" translate="true">
                                                                        Your notice text here.
                                                                    </item>
                                                                </item>
                                                            </item>
                                                        </item>
                                                    </item>
                                                </item>
                                            </item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </item>
            </argument>
        </arguments>
    </referenceBlock>
</body>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.