Skip to content
OSULZER.AT
Code1 min read· updated February 14, 2026

WooCommerce: Hide Prices and Add to Cart Button for Products in a Category

Hide prices and the add to cart button for WooCommerce products in a specific category. A short PHP snippet, you only need to set the category slug.

The following snippet disables the display of prices and the add to cart button for products in a specific category. In both functions, the variable “$category_slug” needs to be adjusted to the category you want.

function hide_prices_and_add_to_cart_button_in_category() {
    // Define the category slug for which prices and "Add to Cart" button will be hidden
    $category_slug = 'your-category-slug';

    // Check if the current page is a WooCommerce product category
    if (is_product_category($category_slug)) {
        // Hide prices
        remove_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10);
        remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 10);

        // Hide "Add to Cart" button
        remove_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10);
        remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
    }
}
add_action('wp', 'hide_prices_and_add_to_cart_button_in_category');

function hide_price_and_add_to_cart_button() {
    // Get the product categories for the current product
    $categories = get_the_terms(get_the_ID(), 'product_cat');

    // Define the category slug for which the price and "Add to Cart" button will be hidden
    $category_slug = 'your-category-slug';

    // Check if the product belongs to the specified category
    if ($categories && !is_wp_error($categories)) {
        foreach ($categories as $category) {
            if ($category->slug === $category_slug) {
                // Hide price
                remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 10);

                // Hide "Add to Cart" button
                remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
                break;
            }
        }
    }
}
add_action('woocommerce_before_single_product', 'hide_price_and_add_to_cart_button');

Learn more about my services as a WooCommerce developer.

WooCommerce Development

Prefer to have it done for you?

Custom plugins, integrations, and B2B features for your shop - €120/h plus VAT.

See WooCommerce development

New project?

Contact.

Tell me briefly about your project - I'll get back to you personally.

Your data is used solely to handle your inquiry. More in the privacy policy.