【问题标题】:How to add notice on magento 2 checkout, on street address field for billing and shipping如何在 magento 2 结账时添加通知,在街道地址字段上进行计费和运输
【发布时间】:2021-08-10 15:08:45
【问题描述】:

我想在 magento 2 结帐页面上的街道地址字段中添加通知。我尝试将其添加到:使用布局过程

<?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;
    }
}

它只为送货地址而不是账单添加任何人可以告诉我如何在付款方式下添加我的账单地址部分

【问题讨论】:

  • 你找到解决办法了吗?
  • @RonakChauhan 是的,我会在这里回答

标签: magento2 checkout addressbook billing street-address


【解决方案1】:

如果需要找到标签的确切位置,只需打印布局过程并在特定标签上添加通知

$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

根据我为街道添加的日志文件检查

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-11-13
    • 2017-04-19
    • 1970-01-01
    • 2014-10-29
    • 1970-01-01
    • 2023-03-16
    • 1970-01-01
    相关资源
    最近更新 更多