A simple, powerful and independent e-commerce platform.
Sell anything with ease.

Hide price and cart button for selected categories

Sometimes a store will have to combine two different functionalities – some items will be for sale online, but others may only need to be displayed as available for purchase. They may be too large or delicate to ship, or they might be advertised as “Price on Application”.  You can hide prices and cart buttons on selected categories, but they need to be hidden in two places – on the category page and on the individual product page. Note that prices will still be shown on the main shop page, so you may also want to disable that page using this code: Redirect main shop page

		/**
 * Hide prices and cart buttons on individual category pages
 */

add_action('woocommerce_after_shop_loop_item_title', 'cc_hide_loop_product_prices', 1);

function cc_hide_loop_product_prices(){
  global $product;

  if(is_product_category(array('category-name1', 'category-name2', 'category-name3'))):

  // Hide prices
  remove_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10);

  // Hide add-to-cart buttons
  remove_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');

  endif;
}

/**
 * Hide prices and cart buttons on single product pages
 */
 
add_action('woocommerce_single_product_summary', 'cc_hide_single_product_prices', 1);

function cc_hide_single_product_prices(){
  global $product;

  if( has_term(array(category-name1', 'category-name2', 'category-name3'), 'product_cat', $product->get_id())):

  // Hide prices
  remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 10);

  // Hide add-to-cart buttons
  remove_action('woocommerce_single_product_summary','woocommerce_template_single_add_to_cart', 30);

  endif;
}
	
View Raw Code ID: 91019