Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save themepaint/535624dd1821e03307f5 to your computer and use it in GitHub Desktop.
Save themepaint/535624dd1821e03307f5 to your computer and use it in GitHub Desktop.
remove add to cart button from a certain category Woocommerce
function themepaint_custom_cart_buttons(){
$product = get_product();
if ( has_term( 'posters', 'product_cat') ){
// removing the purchase buttons
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
remove_action( 'woocommerce_simple_add_to_cart', 'woocommerce_simple_add_to_cart', 30 );
remove_action( 'woocommerce_grouped_add_to_cart', 'woocommerce_grouped_add_to_cart', 30 );
remove_action( 'woocommerce_variable_add_to_cart', 'woocommerce_variable_add_to_cart', 30 );
remove_action( 'woocommerce_external_add_to_cart', 'woocommerce_external_add_to_cart', 30 );
}
}
add_action( 'wp', 'themepaint_custom_cart_buttons' );
@oscararroliga
Copy link

Hello, what if i need include more than one category?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment