【问题标题】:Woocommerce Removing "Additional information" Name On Checkout PageWoocommerce 在结帐页面上删除“附加信息”名称
【发布时间】:2014-04-24 08:48:19
【问题描述】:

在我的 Wordpress Woocommerce 网站中,我删除了所有运输和账单详细信息,因此客户只需输入他们的第一个、最后一个和电子邮件。我正在销售垂直产品,我不想要或不需要所有这些细节。我仍然看到的是附加信息名称仍在显示。

您的信息

名字 *

姓氏*

电子邮件地址 *

确认电子邮件地址 *

其他信息

当我从我看到的页面中查看 html 时:

</p></div>
</p></div>
<div class="col-2">
<div class="woocommerce-shipping-fields">
<h3>Additional Information</h3>
</p></div>  
</p></div>
</p></div>

这是一些如何插入,所以我不能只是删除它。如果可以,请提供见解如何找到它可能在哪个文件中。

这是我包含在我的子主题中的代码,用于删除所有账单和运输信息:

// Hook in
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );

// Our hooked in function - $fields is passed via the filter!
function custom_override_checkout_fields( $fields ) {
unset($fields['order']['order_comments']);
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_address_1']);
unset($fields['billing']['billing_address_2']);
unset($fields['billing']['billing_city']);
unset($fields['billing']['billing_postcode']);
unset($fields['billing']['billing_country']);
unset($fields['billing']['billing_state']);
unset($fields['billing']['billing_phone']);

return $fields;
}

提前感谢您的有用建议

【问题讨论】:

    标签: wordpress woocommerce checkout


    【解决方案1】:

    尝试将此添加到您的functions.php中

    add_filter('woocommerce_enable_order_notes_field', '__return_false');
    

    【讨论】:

    • 您从哪里获得此代码?它对我有用,但我想了解如何找到此信息? =)
    • 嗨,您可以在 woocommerce/templates/checkout/form-shipping.php 行 62 上看到 woocommerce 使用过滤器
    【解决方案2】:

    附加信息标题位于文件中:

    wp-content/plugins/woocommerce/templates/checkout/form-shipping.php
    

    但是我建议您创建一个child theme 并在那里进行自定义。添加@qutek 推荐的过滤器也可以。

    如果你想摆脱结帐自带的 2 列样式,你应该使用位于文件中的“customer_details” id 自定义 div:

    wp-content/plugins/woocommerce/templates/checkout/form-checkout.php
    

    【讨论】:

      【解决方案3】:

      要删除整个附加信息部分,请使用:-

      add_filter('woocommerce_enable_order_notes_field', '__return_false');
      

      如果您只想删除附加信息文本:-

      function wc_order_review_strings( $translated_text, $text, $domain ) {
      
        if(is_checkout()){
          switch ($translated_text) {
            case 'Billing details' :
              $translated_text = __( 'Billing Info', 'woocommerce' );
              break;
            case 'Additional information':
              $translated_text = __('New Field Name', 'woocommerce');
              break;
           case 'Your order':
              $translated_text = __('My Order', 'woocommerce');
              break;
           case 'Product':
              $translated_text = __('Your Product', 'woocommerce');
              break;
          }
        }
        return $translated_text;
      }
      add_filter( 'gettext', 'wc_order_review_strings', 20, 3 );
      

      【讨论】:

        猜你喜欢
        • 2017-09-13
        • 2016-06-15
        • 2015-09-09
        • 1970-01-01
        • 2018-05-21
        • 1970-01-01
        • 2019-01-22
        • 2019-08-23
        • 1970-01-01
        相关资源
        最近更新 更多