How to hide 'Add To Cart' for variable pro

2019-06-08 07:10发布

When I try to hide the 'Add to cart' button, the variations disappear.

2条回答
对你真心纯属浪费
2楼-- · 2019-06-08 07:47

I did this, since I have variable products on separate RETAIL pages that I want to keep the 'Add to cart' button

 function remove_add_to_cart(){
    if ( has_term( 'wholesale', 'product_tag' ) ) {

        remove_action( 'woocommerce_single_variation','woocommerce_single_variation_add_to_cart_button', 20 );
}
} 

add_action('woocommerce_single_variation','remove_add_to_cart');
查看更多
走好不送
3楼-- · 2019-06-08 07:52

Here is the way to remove add to cart button and quantities in Single product pages for variable products only, keeping the attributes select fields:

add_action( 'woocommerce_single_product_summary', 'hide_add_to_cart_button_variable_product', 1, 0 );
function hide_add_to_cart_button_variable_product() {

    // Removing add to cart button and quantities only
    remove_action( 'woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20 );
}

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

Tested and works.

查看更多
登录 后发表回答