如何在街道地址栏上的magento 2 checkout上添加工具提示?

问题描述 投票:0回答:1

我想在街道地址字段上添加工具提示,在magento 2结帐页面上。我尝试将其添加到:vendor \ magento \ module-checkout \ view \ frontend \ layout \ checkout_index_index.xml

<item name="street" xsi:type="array"> 
   <item name="config" xsi:type="array"> 
      <item name="tooltip" xsi:type="array"> 
        <item name="description" xsi:type="string" translate="true">For delivery address verification.</item> 
      </item> 
   </item> 
</item>
forms magento checkout
1个回答
0
投票

你可以创建一个after plugin来向街道字段添加工具提示,你需要注入checkout LayoutProcessor

Class LayoutProcessor
{
 /**
  * @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'][0]['tooltip']['description'] = "ToolTip 1";
    $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
        ['shippingAddress']['children']['shipping-address-fieldset']['children']['street']['children'][1]['tooltip']['description'] = "ToolTip 2";

    return $jsLayout;
 }
} 

enter image description here

enter image description here

请参考这个POST

© www.soinside.com 2019 - 2024. All rights reserved.