How to add a Specifications tab to WooCommerce products
Electronics, tools, furniture and parts shoppers compare specifications before they buy. A Specifications tab can fill in each product's own SKU, weight and dimensions, so you never type them twice. WooCommerce doesn't include one, so here are two ways to add it: a short code snippet, or the free ShelfTabs plugin with no code.
Short version: Developers can paste the snippet below. Everyone else can install free ShelfTabs, add the Electronics & gadgets pack, and edit the Specifications tab.
Option 1: A code snippet
This adds a Specifications tab to every product and fills in the SKU, weight and dimensions you already entered under Product data → Inventory and Shipping. Empty values are left out. We tested it on WooCommerce with both a block theme and a classic theme.
add_filter( 'woocommerce_product_tabs', function ( $tabs ) {
$tabs['specifications'] = array(
'title' => 'Specifications',
'priority' => 15,
'callback' => function () {
global $product;
$rows = array(
'SKU' => $product->get_sku(),
'Weight' => $product->get_weight() ? wc_format_weight( $product->get_weight() ) : '',
'Dimensions' => $product->has_dimensions() ? wc_format_dimensions( $product->get_dimensions( false ) ) : '',
);
echo '<h2>Specifications</h2><table class="woocommerce-table shop_attributes">';
foreach ( $rows as $label => $value ) {
if ( '' !== $value ) {
echo '<tr><th>' . esc_html( $label ) . '</th><td>' . esc_html( $value ) . '</td></tr>';
}
}
echo '</table>';
},
);
return $tabs;
} );
Where to put it: In the free Code Snippets plugin, or in your child theme's functions.php. Don't edit your main theme's files, because a theme update would erase your change.
Option 2: No code, with ShelfTabs (free)
- Download shelftabs.zip (don't unzip it). In WordPress, go to Plugins → Add New → Upload Plugin, choose the file, click Install Now, then Activate.
- Go to WooCommerce → ShelfTabs. Under Start from a ready-made pack, click Add this pack on Electronics & gadgets.
- Click Edit next to Specifications, replace the text in [brackets] with your own, and save.
- Open a product, go to Product data → Product tabs, choose Specifications, and update the product.
With ShelfTabs Pro, one rule shows the tab on every product in a category automatically, and merge tags fill in each product's own details, such as its SKU, weight or dimensions.
Skip the code
ShelfTabs is free and includes ready-made tabs for 10 kinds of store. ShelfTabs Pro adds automatic tabs by category, from $29 a year with a 30-day refund if it doesn't work.
Download free ShelfTabs See ShelfTabs