Sunday, 8 May 2016

WooCommerce editing product tabs on single product page

Removing Tabs

Use the following snippet in functions.php of your theme to remove specific tabs from single product page.


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

Use the following snippet in functions.php of your theme to rename specific tabs on single product page.

add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_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

Use the following snippet in functions.php of your theme to change the tab order on single product page.

add_filter( 'woocommerce_product_tabs', 'woo_reorder_tabs', 98 );
function woo_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;
}

No comments: