wordpress Woocommerce 在结帐页面上删除“附加信息”名称

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22483312/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:30:05  来源:igfitidea点击:

Woocommerce Removing "Additional information" Name On Checkout Page

wordpresswoocommercecheckout

提问by user3433648

In my Wordpress Woocommerce site I have removed all of the shipping and billing details so the customer only has to enter their first, last and email. I'm selling vertical products, I don't want or need all those details. What I'm still seeing is Additional Informationname is still showing up.

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

Your Information

你的资料

First Name *

名 *

Last Name *

姓 *

Email Address *

电子邮件地址 *

Confirm Email Address *

确认电邮地址 *

Additional Information

附加信息

When I look at the html from the page I see:

当我从页面查看 html 时,我看到:

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

It's some how plugged in so I can't just delete it. If I can please give insight how to find what file it might be in.

这是一些插入方式,所以我不能删除它。如果可以的话,请深入了解如何找到它可能在哪个文件中。

This is the code I've included in my child theme to remove all billing and shipping info:

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

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

Thanks in advance for helpful advice

预先感谢有用的建议

回答by Lafif Astahdziq

try to add this to your functions.php

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

add_filter('woocommerce_enable_order_notes_field', '__return_false');

回答by javidazac

The Additional Informationtitle is located in file:

附加信息标题位于文件:

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

However i recommend you to create a child themeand make your customizations there. Adding the filter that @qutek recommends also works.

但是我建议您创建一个子主题并在那里进行自定义。添加@qutek 推荐的过滤器也有效。

If you want to get rid of the 2 columns style that the checkout comes with, you should customize the div with the "customer_details" id located in file:

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

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

回答by Amit Garg

To remove the whole Additional information section use:-

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

add_filter('woocommerce_enable_order_notes_field', '__return_false');

And If you just want to remove the Additional information text:-

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

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 );