SKU, Category list and Tag list on the WooCommerce single product page are called “product meta”. We already saw how to hide just the SKU (while leaving Cats and Tags there), so in this “episode” we will study how to do the opposite i.e. keeping the SKU there while hiding Cats and/or Tags.

If you are a developer, you’d think there were a specific WooCommerce “filter” for this, but there is not. So, we have to first remove the whole “product meta” block and then add back the info we want (just the Cats, for example). If you’re not a dev – not to worry – just copy paste one of the snippets below in your functions.php and magic will happen. Enjoy!

We’re looking at the “Product Meta” section on the single product page. Our goal is to hide categories and tags and leave SKU where it is now.

PHP Snippet 1: Hide “SKU” & “Category:__” & “Tag:__” @ WooCommerce Single Product Page

Basically, in here we go and remove the whole “Product Meta” block. And thankfully, it’s just 1 line of code.

If you want to add back just the SKU, just the Cats or just the Tags, use snippet 2, 3 or 4 together with this one.

/**
 * @snippet       Hide SKU, Cats, Tags @ Single Product Page - WooCommerce
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WC 3.8
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */
  
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );

PHP Snippet 2: Show “SKU”Again @ WooCommerce Single Product Page

This is equivalent to saying “Hide Categories and Tags” from product meta. Basically after removing the whole product meta block, we’re readding the SKU.

/**
 * @snippet       Show SKU Again @ Single Product Page - WooCommerce
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WC 3.8
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

add_action( 'woocommerce_single_product_summary', 'bbloomer_show_sku_again_single_product', 40 );

function bbloomer_show_sku_again_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
}


PHP Snippet 3: Show “Categories:” Again @ WooCommerce Single Product Page

/**
 * @snippet       Show Categories Again @ Single Product Page - WooCommerce
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WC 3.8
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

add_action( 'woocommerce_single_product_summary', 'bbloomer_show_cats_again_single_product', 40 );

function bbloomer_show_cats_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
}


PHP Snippet 4: Show “Tags:” Again @ WooCommerce Single Product Page

/**
 * @snippet       Show Tags Again @ Single Product Page - WooCommerce
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WC 3.8
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

add_action( 'woocommerce_single_product_summary', 'bbloomer_show_tags_again_single_product', 40 );

function bbloomer_show_tags_again_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
}


Share:

Leave a Reply