Woocommerce Product Template

This is a Developer level doc. If you are unfamiliar with code/templates and resolving potential conflicts, select a WooExpert or Developer for assistance. We are unable to provide support for customizations under our Support Policy.

  • Woocommerce / templates / archive-product.php / Jump to. The Template for displaying product archives, including the main shop page which is a post type archive.
  • The products shortcode is one of our most robust shortcodes, which can replace various other strings used in earlier versions of WooCommerce. The products shortcode allows you to display products by post ID, SKU, categories, attributes, with support for pagination, random sorting, and product tags, replacing the need for multiples shortcodes such as featuredproducts, saleproducts.
This is a Developer level doc. If you are unfamiliar with code/templates and resolving potential conflicts, select a WooExpert or Developer for assistance. We are unable to provide support for customizations under ourSupport Policy.

You need to add the code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Code snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be wiped entirely when you update the theme.

Removing Tabs↑ Back to top

Use the following snippet to remove specific tabs

/**
* Remove product data tabs
*/
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
unset( $tabs['description'] ); // Remove the description tab
unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
return $tabs;
}

Renaming Tabs ↑ Back to top

Use the following snippet to rename tabs.

/**
* Rename product data tabs
*/
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
functionwoo_rename_tabs( $tabs ) {
$tabs['description']['title'] =__( 'More Information' ); // Rename the description tab
$tabs['reviews']['title'] =__( 'Ratings' ); // Rename the reviews tab
$tabs['additional_information']['title'] =__( 'Product Data' ); // Rename the additional information tab
return$tabs;
}

Re-ordering Tabs ↑ Back to top

Use the following snippet to change the tab order

/**
* Reorder product data tabs
*/
add_filter( 'woocommerce_product_tabs', 'woo_reorder_tabs', 98 );
functionwoo_reorder_tabs( $tabs ) {
$tabs['reviews']['priority'] =5; // Reviews first
$tabs['description']['priority'] =10; // Description second
$tabs['additional_information']['priority'] =15; // Additional information third
return$tabs;
}

Customize a tab ↑ Back to top

The following snippet will replace the description tab with a custom function

/**
* Customize product data tabs
*/
add_filter( 'woocommerce_product_tabs', 'woo_custom_description_tab', 98 );
functionwoo_custom_description_tab( $tabs ) {
$tabs['description']['callback'] ='woo_custom_description_tab_content'; // Custom description callback
return$tabs;
}
functionwoo_custom_description_tab_content() {
echo'<h2>Custom Description</h2>';
echo'<p>Here's a custom description</p>';
}

Add a custom tab ↑ Back to top

Use the following snippet to add a custom global product tab

/**
* Add a custom product data tab
*/
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
// Adds the new tab
$tabs['test_tab'] = array(
'title' => __( 'New Product Tab', 'woocommerce' ),
'priority' => 50,
'callback' => 'woo_new_product_tab_content'
);
return $tabs;
}
function woo_new_product_tab_content() {
// The new tab content
echo '<h2>New Product Tab</h2>';
echo '<p>Here's your new product tab.</p>';
}

The Additional Information tab ↑ Back to top

Please note that the “Additional Information” tab will only show if the product has weight, dimensions or attributes (with “Visible on the product page” checked). If you try to apply a change to that tab and if the product does not have weight, dimensions or attribute, you will get an error message similar to :

Warning: call_user_func() expects parameter 1 to be a valid callback, no array or string given in /mysite/wp-content/plugins/woocommerce/templates/single-product/tabs/tabs.php on line 35

Joomla amazon

Woocommerce Template Product List

Woocommerce Product Template

In that case, you have to use WooCommerce conditional tags:

Woocommerce Product Template Csv

  • has_attributes()
  • has_dimensions()
  • has_weight()

Woocommerce Template Page

/**
* Check if product has attributes, dimensions or weight to override the call_user_func() expects parameter 1 to be a valid callback error when changing the additional tab
*/
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {
global $product;
if( $product->has_attributes() $product->has_dimensions() $product->has_weight() ) { // Check if product has attributes, dimensions or weight
$tabs['additional_information']['title'] = __( 'Product Data' ); // Rename the additional information tab
}
return $tabs;
}