WooCommerce: “Explode” Product Tabs

If you like the Amazon single product page layout, you probably dislike the default WooCommerce single product page tabs layout. This is the section where, by default, “Description”, “Reviews”, “Additional Information” and other custom content show… as tabs below the image & short description.

Thankfully, there is a super easy way to remove such tabs and display each tab on top of each other, without hiding any content. If it’s good for your users, then I recommend you make use of this super simple snippet.

In this tutorial, you will learn about “pluggable functions”. Basically, where provided, you can simply redeclare a custom plugin (WooCommerce) function without having to use hooks or overrides. WordPress will just “listen” to your new version and not the original one any longer.

So, enjoy!

Here’s the new layout after tabs “exploded”. As you can see, “Description”, “Reviews” and other tabs are stacked on top of each other and they are all visible. Cool, huh?

PHP Snippet: Stacking Product Tabs On Top Of Each Other @ WooCommerce Single Product Page

First of all, as I already said, tabs are displayed by WooCommerce thanks to this “pluggable” function:

if ( ! function_exists( 'woocommerce_output_product_data_tabs' ) ) {

	/**
	 * Output the product tabs.
	 */
	function woocommerce_output_product_data_tabs() {
		wc_get_template( 'single-product/tabs/tabs.php' );
	}
}

That’s great, so we can simply redeclare the woocommerce_output_product_data_tabs() PHP function and tell WordPress to listen to our new version:

/**
 * @snippet       Explode Tabs @ WooCommerce Single Product Page
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @testedwith    WooCommerce 5
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

function woocommerce_output_product_data_tabs() {
	$product_tabs = apply_filters( 'woocommerce_product_tabs', array() );
	if ( empty( $product_tabs ) ) return;
	echo '<div class="woocommerce-tabs wc-tabs-wrapper">';
	foreach ( $product_tabs as $key => $product_tab ) {
		?>
			<h2><?php echo $product_tab['title']; ?></h2>		
			<div id="tab-<?php echo esc_attr( $key ); ?>">
				<?php
				if ( isset( $product_tab['callback'] ) ) {
					call_user_func( $product_tab['callback'], $key, $product_tab );
				}
				?>
			</div>
		<?php			
	}
	echo '</div>';
}

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (delete "?>" if you have it there). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.3.

If you think this code saved you time & money, feel free to join 14,000+ WooCommerce Weekly subscribers for blog post updates or 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

13 thoughts on “WooCommerce: “Explode” Product Tabs

  1. After i have ‘exploded’ the contents (long product description & reviews), there are 2 Description and 1 Review Header.

    How do i remove both headers?

    1. Hi Adrian!

      Simply remove this line:

      <h2><?php echo $product_tab['title']; ?></h2>
  2. This is a great feature. It does have 2 Descriptions and 2 Additional Information. How do delete one of each?

    Thannks.

    1. You mean 2 titles or the full tabs are duplicated?

  3. Thank you very much! :)))

    I discovered your site looking for this function and I’m enjoying everything here…

    First I tried to add this snippet via the Code Snippets plugin, but it did not allow me to publish, returning the message: “Cannot redeclare function woocommerce_output_product_data_tabs.”

    In functions.php it worked perfectly, however, the titles of the tabs are not shown anymore.

    The content was completely sequential, without being divided by the titles “Description”, “Additional Information”, “Review”, etc.

    Should this happen? How is it possible to show these titles again? Or, how can I show custom titles?

    Thank you again.

  4. Hi Rodolfo, when I try to activate this snippet I get the following error message:

    The code snippet has been disabled due to an error on line 2:

    Unable to redeclare the woocommerce_output_product_data_tabs function.

    1. Hello Tomas! Where did you place this code?

      1. Hi Rodolfo, with code snippets

        1. This won’t work with Code Snippets, you must place this code in your child theme’s functions.php

      2. Hi! Thank you so much for all of your snippets. They are awesome! I get an error when I use the snippets plugin. I guess I should add the code elsewhere. Can you tell me where? Thanks for everything you do!

        1. Hi Chris, functions.php of your child theme

          1. Code works but no titles for each section. anyway to get that back?

            1. Try with this revised version

Questions? Feedback? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)

Your email address will not be published.