如何在街道地址字段的magento 2结帐上添加工具提示?

时间:2019-04-17 13:38:54

标签: forms magento checkout

我想在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>

1 个答案:

答案 0 :(得分: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