1

I would like to ask additional info about this topic: How can I merge the Description and Additional Information tabs in WooCommerce?

My only problem is I want the additional info displayed first. This is a screenshot: https://i.stack.imgur.com/UTIbf.png Here is the link to the site: https://adisport.hu/termek/adidas-xz-torsion/

This is the code I used in function.php:

// Remove Additional Info tab
add_filter('woocommerce_product_tabs', 'remove_tab_additional_info', 30);
function remove_tab_additional_info($tabs){
    unset( $tabs['additional_information'] );
    return $tabs;
}

// Add original Additional Info tab info to the end of the_content
add_filter('the_content','add_details_to_content', 10, 1);
function add_details_to_content($content){
    if ( is_product() ){
        global $product;
        $content = '<div class="product-description">'.$content.'</div>';

        ob_start();
        ?><div class="product-additional-info"><?php

        $heading = apply_filters( 'woocommerce_product_additional_information_heading', __( 'Additional information', 'woocommerce' ) );
        if ( !empty($heading) ) {
        ?>
            <h3><?php echo esc_html( $heading ); ?></h3>
        <?php }

        do_action( 'woocommerce_product_additional_information', $product );
        ?></div><?php
        $content .= ob_get_clean();
    }
    return $content;
}
LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399

1 Answers1

0

Try the following:

// Remove Additional Info tab
add_filter( 'woocommerce_product_tabs', 'remove_tab_additional_info', 30 );
function remove_tab_additional_info( $tabs ){
    unset( $tabs['additional_information'] );
    return $tabs;
}

add_filter( 'the_content', 'add_additional_info_before_content' );
function add_additional_info_before_content( $content ){
    if ( is_product() ){
        global $product;

        ob_start();
        
        echo '<div class="product-additional-info">';
        
        $hook    = 'woocommerce_product_additional_information_heading';
        $heading = apply_filters( $hook, __( 'Additional information', 'woocommerce' ) );
        
        if ( !empty($heading) ) {
            echo '<h3>' . esc_html( $heading ) . '</h3>';
        }

        do_action( 'woocommerce_product_additional_information', $product );
        
        echo '</div>';
        
        $content = ob_get_clean() . '<div class="product-description">' . $content . '</div>';
    }
    return $content;
}

Tested and works.

Related: Add custom content to WooCommerce product description

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399