在 WooCommerce 中隐藏购物车项目标题的变化信息 3+ [英] Hide variation info from cart item title in WooCommerce 3+
问题描述
自从我们升级到 Woocommerce 版本 3 后,我们的订单确认就显示了包含变体详细信息的大量标题.我不喜欢它的外观,它破坏了一些定制插件中的一些重要功能.
Ever since we upgraded to Woocommerce version 3 our order confirmations are showing huge titles that include the variation detail. I don't like how it looks and it breaks some important functionalities in some custom-made plugins.
据我所知,有一个过滤器可用于禁止在名为 woocommerce_product_variation_title_include_attribute_name
的标题中显示此数据.但我不知道在哪里应用过滤器.
There is a filter that can be used to disable this data displaying in the title called woocommerce_product_variation_title_include_attribute_name
from what I understand. But I have no idea where to apply the filter.
是否有一种快速的方法可以应用过滤器将其改回以前的显示状态?
Is there a quick way to apply the filter to change it back to display as it did before?
推荐答案
此过滤器应该可以为 woocommerce_product_variation_title_include_attributes
以这种方式过滤钩子:
This filter should work returning a false
value for $should_include_attributes
first argument in woocommerce_product_variation_title_include_attributes
filter hook this way:
add_filter( 'woocommerce_product_variation_title_include_attributes', 'custom_product_variation_title', 10, 2 );
function custom_product_variation_title($should_include_attributes, $product){
$should_include_attributes = false;
return $should_include_attributes;
}
代码位于活动子主题(或主题)的 function.php 文件或任何插件文件中.
它应该像您期望的那样工作.
It should just work as you expect.
更新:更短的方法是:
add_filter( 'woocommerce_product_variation_title_include_attributes', '__return_false' );
代码位于活动子主题(或主题)的 function.php 文件或任何插件文件中.
也能用.
这篇关于在 WooCommerce 中隐藏购物车项目标题的变化信息 3+的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!