customize woocommerce actions on products within a specific category

change #### with either the term name, the term_id, the slug, or an array of multiple - wordpress codex

function customize_that_product_in_a_category() {
global $product;
if( has_term('####', 'product_cat') ) {
//insert actions to add/remove here
}
}
add_action( 'woocommerce_before_single_product', 'customize_that_product_in_a_category', 05 );

customize woocommerce actions on a specific category

replace slug-here with the product category slug or an array of slugs - woocommerce docs

function customize_that_category() {
global $product;
if( is_product_category( 'slug-here' ) ) {
//insert actions to add/remove here
}
}
add_action( 'woocommerce_before_main_content', 'customize_that_category', 05 );

customize woocommerce actions on a specific product

replace #### with either the post_id, title, slug or an array of multiple - wordpress.org code reference

function customize_that_product() {
global $product;
if( is_single('####') ) {
//insert actions to add/remove here

}
}
add_action( 'woocommerce_before_single_product', 'customize_that_product', 05 );

add to functions.php

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.