Php “如何禁用”;“添加到购物车”;在多个商业类别中

Php “如何禁用”;“添加到购物车”;在多个商业类别中,php,wordpress,woocommerce,Php,Wordpress,Woocommerce,我正在尝试从多个类别中删除“添加到购物车”按钮。我已将此代码放在functions.php文件中: //function for deleting .... function remove_product_description_add_cart_button(){ global $product; // Set HERE your category ID, slug or name (or an array) $category = 'categoryslug';

我正在尝试从多个类别中删除“添加到购物车”按钮。我已将此代码放在functions.php文件中:

//function for deleting ....
function remove_product_description_add_cart_button(){
    global $product;

    // Set HERE your category ID, slug or name (or an array)
    $category = 'categoryslug';

    //Remove Add to Cart button from product description of product with id 1234    
    if ( has_term( $category, 'product_cat', $product->id ) )
        remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );

}
add_action('wp','remove_product_description_add_cart_button');

但我的问题是,它只从指定的一个类别中删除“添加到购物车”。我试图修改代码以允许多个类别,但我所做的一切都不起作用。有人有什么想法吗?谢谢。

如果这有帮助的话:我只想允许购买特定类别的商品,其他所有类别的商品都可以隐藏“添加到购物车”和paypal按钮。您尝试过这个条件吗
有\u术语(数组($category1,$category2),'product\u cat',$product->id)
?如果产品具有类别1或类别2,则删除操作