自从我们升级到Woocommerce版本3以来,我们的订单确认显示了巨大的标题,其中包括变化的细节。我不喜欢它的外观,它破坏了一些定制插件的一些重要功能。
参考资料:订单名称显示自WC版本3更新以来的变化
据我所知,有一个过滤器可以用于禁用标题中的数据显示,名为woocommerce_product_variation_title_include_attribute_name
。但我不知道该在哪里应用过滤器。
是否有一种快速的方法来应用过滤器将其更改为与以前一样的显示?
发布于 2017-07-01 00:56:17
此筛选器应以这种方式为false
过滤器钩子中的$should_include_attributes
第一个参数返回一个woocommerce_product_variation_title_include_attributes值:
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文件中,或者在任何插件文件中。
它应该像你期望的那样起作用。
更新:更短的方式是:
add_filter( 'woocommerce_product_variation_title_include_attributes', '__return_false' );
代码在您的活动子主题(或主题)的function.php文件中,或者在任何插件文件中。
也很管用。
发布于 2020-05-12 06:32:38
如果您正在使用此筛选器从电子邮件项中删除属性,则很快就会发现。看来,一旦一个项目被写入一个顺序,它的属性将不会改变。
add_filter( 'woocommerce_product_variation_title_include_attributes', '__return_false' );
发布于 2020-05-14 06:28:08
正如@freemason_17所指出的那样,@LoicTheAztec的答案可能也会将这些细节隐藏在其他地方,因此,为了确保我添加了一个条件,可以将其限制在购物车页面上:
function custom_product_variation_title($should_include_attributes, $product){
if(is_cart()) {
$should_include_attributes = false;
return $should_include_attributes;
}
}
add_filter( 'woocommerce_product_variation_title_include_attributes', 'custom_product_variation_title', 10, 2 );
https://stackoverflow.com/questions/44839975
复制