WooCommerce: Hide SKU, Category & Tag On Single Product Page

When viewing the single product page in WooCommerce, usually we will find the product SKU, Category List and Tag list below the Add To Cart button. This data is known as the “product meta”.

If you’re looking to hide the product categories and product tags on your single product page look no further.

Unfortunately there is not a WooCommerce filter to remove just the product categories and tags, while keeping the SKU; so we’ll remove the entire product meta section and add back in the SKU.

Hide Product Meta (SKU, Categories & Tags) from WooCommerce Single Product Page

Head to your functions.php document and add the following snippet.

If you want to add back just the SKU, just the Cats or just the Tags, use the next snippets as well.

/**
* @snippet       Hide Product SKU, Categories, Tags on Single Product Page - WooCommerce
*/
   
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );

 

Show Product SKU on WooCommerce Single Product Page

After removing the whole product meta block, the following snippet will re-add the SKU

/**
* @snippet       Show Product SKU on Single Product Page - WooCommerce
*/
 
add_action( 'woocommerce_single_product_summary', 'custom_show_sku_single_product', 40 );
 
function custom_show_sku_single_product() {
global $product;
?>
<div class="product_meta">
   <?php if ( wc_product_sku_enabled() && ( $product->get_sku() || $product->is_type( 'variable' ) ) ) : ?>
      <span class="sku_wrapper"><?php esc_html_e( 'SKU:', 'woocommerce' ); ?> <span class="sku"><?php echo ( $sku = $product->get_sku() ) ? $sku : esc_html__( 'N/A', 'woocommerce' ); ?></span></span>
   <?php endif; ?>
   </div>
   <?php
}

 

Show “Categories” on WooCommerce Single Product Page

After removing the whole product meta block, the following snippet will re-add the Categories

/**
 * @snippet       Show Categories on Single Product Page - WooCommerce
 */
 
add_action( 'woocommerce_single_product_summary', 'custom_show_categories_again_single_product', 40 );
 
function custom_show_categories_again_single_product() {
global $product;
?>
   <div class="product_meta">
   <?php echo wc_get_product_category_list( $product->get_id(), ', ', '<span class="posted_in">' . _n( 'Category:', 'Categories:', count( $product->get_category_ids() ), 'woocommerce' ) . ' ', '</span>' ); ?> 
   </div>
   <?php
}
 

 

Show “Tags” on WooCommerce Single Product Page

/**
 * @snippet       Show Tags on Single Product Page - WooCommerce
 */
 
add_action( 'woocommerce_single_product_summary', 'custom_show_tags_single_product', 40 );
 
function custom_show_tags_single_product() {
global $product;
?>
   <div class="product_meta">
   <?php echo wc_get_product_tag_list( $product->get_id(), ', ', '<span class="tagged_as">' . _n( 'Tag:', 'Tags:', count( $product->get_tag_ids() ), 'woocommerce' ) . ' ', '</span>' ); ?> 
   </div>
   <?php
}

To use any of the PHP snippets above, place them in your functions.php file in your theme folder. If you’re using a child theme, ensure your snippets are placed in the child theme functions.php file.

If you need assistance with implementing customisations to your WooCommerce website, please don’t hesitate to contact me.

Posted on December 1, 2019 | Categories: Blog