how can i add notice or lable in checkout page below the state field just like notice below the email address in blow image,

state input element is created by region_id field in vendor\magento\module-checkout\view\frontend\layout\checkout_index_index.xml

<item name="customEntry" xsi:type="string">shippingAddress.region</item>

enter image description here

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
scroll top