我的所有产品都有属性,例如“选择您的尺寸”和“选择您的颜色”,但是在购物篮和结帐时,我想从所有属性中删除“选择您的”,以便它不显示。
是否有一种简单的方法可以在 Woocommerce 模板文件中执行此操作?
最佳答案
与此作斗争将是一场世纪之战...您不仅需要删除其中的该字符串...它也将像发送的电子邮件和订单页面上显示的那样。还有一些我不记得的页面...
我认为您只想在产品页面中显示“选择您的”字符串,不是吗?
如果是这样,为什么不在其中添加该字符串?
因此,在您的变体中,在产品管理页面中,将变体添加为 size
。然后更改产品页面中的显示,如下所示:
add_filter('woocommerce_attribute_label','reigel_attribute_label', 10, 2);
function reigel_attribute_label( $label, $name ) {
if (is_product() && $label == 'size') {
$label = 'Select your ' . $label;
}
// another if statement if needed...
if (is_product() && $label == 'color') {
$label = 'Select your ' . $label;
}
return $label;
}
通过这种方法,您只需在产品页面中选择选择您的尺码
...
关于php - 结帐时从 Woocommerce 产品属性中删除单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35741879/