我遇到了如何从类别产品中删除购物车的问题。如果我将它应用于特定的ID或一般情况下,它就可以工作,但我无法为某个类别做到这一点。以下是我已经完成的代码。删除Woocommerce中针对特定产品类别的添加购物车按钮
此外,我正在努力将相同的模式应用到相关文章部分,所以任何帮助,将不胜感激。
谢谢。
//function for deleting ....
function remove_product_description_add_cart_button(){
global $product;
//Remove Add to Cart button from product description of product with id 1234
if ($product->id == 188){
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
}
add_action('wp','remove_product_description_add_cart_button');
}