Book Image

WooCommerce Cookbook

By : Patrick Rauland
Book Image

WooCommerce Cookbook

By: Patrick Rauland

Overview of this book

Table of Contents (17 chapters)
WooCommerce Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Reordering product tabs


You may not want to remove product tabs entirely. You may only want to rearrange them. That can also be done with a bit of code.

Getting ready

You should know how to find the product tab ID. This is discussed in the first part of the preceding recipe, Removing product tabs.

How to do it…

To reorder product tabs, take a look at the following steps:

  1. Open up your theme's functions.php file, or a custom WooCommerce plugin that you have created, and paste in the following:

    add_filter( 'woocommerce_product_tabs', 'woocommerce_cookbook_reorder_tabs', 98 );
    function woocommerce_cookbook_reorder_tabs( $tabs )
    { 
        return $tabs;
    }
  2. In the woocommerce_cookbook_reorder_tabs function, you'll want to paste in the new order. Add the following code before the return $tabs; statement:

    if( isset( $tabs['reviews']['priority'] ) ){
        $tabs['reviews']['priority'] = 10;
    }
    if( isset( $tabs['description']['priority'] ) ){
        $tabs['description']['priority'] = 20;
    }
    if( isset( $tabs['additional_information...