How to add notice on magento 2 checkout, on street address field for billing and shipping

1k Views Asked by At

I want to add notice on street address field, on magento 2 checkout page. I tried adding it in: using layout process

<?php
namespace Pawan\Notice\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']['street']['children'][1]
            ['notice'] = __('This is my custom notice.');
       $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
            ['billingAddress']['children']['billing-address-fieldset']['children']['street']['children'][1]
            ['notice'] = __('This is my custom notice.');
        
       
        return $jsLayout;
    }
}

it added only for shipping address but not billing can any one tell me how to add my billing address section under payment method

1

There are 1 best solutions below

0
Pawankumar N On

If need find exact place of tags just print layout process and add notice to particular tag

$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/extranotice.log');
        $logger = new \Zend\Log\Logger();
        $logger->addWriter($writer);
        $logger->info('Simple Text Log'); // Simple Text Log
        $logger->info('Array Log $jsLayout'.print_r($jsLayout, true)); // Array Log

checked on log file based on that I added for street

$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
        ['shippingAddress']['children']['shipping-address-fieldset']['children']['street']['children'][0]
        ['notice'] = __('No PO Box');