Skip to content
Advertisement

Move product meta to the description tab in WooCommerce

How to move the product meta to the beginning of the product description tab? I try:

remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
add_action( 'woocommerce_product_tabs_description', 'woocommerce_template_single_meta', 10 );

Remove works, but add_action() doesn’t.

Advertisement

Answer

You can keep the first code line. Then to insert single product meta on product description tab, before description, you can use 2 different ways:

1). Using Hooks as follows:

remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );

add_filter( 'woocommerce_product_tabs', 'woocommerce_custom_product_tabs', 999 );
function woocommerce_custom_product_tabs( $tabs ) {
    // We overwrite the callback function with a custom one
    $tabs['description']['callback'] = 'woocommerce_product_meta_and_description_tab';

    // (optional) We can also overwrite the title
    $tabs['description']['title'] = __('Meta and description', 'woocommerce');

    return $tabs;
}

function woocommerce_product_meta_and_description_tab() { // this is where you indicate what appears in the description tab
    wc_get_template( 'single-product/meta.php' ); // The meta content first
    wc_get_template( 'single-product/tabs/description.php' ); // The product description after
}

Code goes in functions.php file of the active child theme (or active theme). Tested and works.


2). Or Overriding templates:

You can override single-product/tabs/description.php template file via your theme as explained in this official documentation.

Once you have copied the file to the woocommerce folder inside your active theme, open edit single-product/tabs/description.php file and add the following line inside it:

wc_get_template( 'single-product/meta.php' );

It will displays the product meta information inside the product description tab.

Don’t forget to keep in your active child theme’s functions.php file:

remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );

Related: WooCommerce action hooks and overriding templates

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement