H
H
hooli-gun2021-08-05 13:23:08
WordPress
hooli-gun, 2021-08-05 13:23:08

How to display only reviews in woocommerce tabs?

How to make it so that it would display only reviews without additional information?

<div class="woocommerce-product__tabs woocommerce-tabs wc-tabs-wrapper tabs">
        <div class="woocommerce-product__tabs-links">
            <div class="woocommerce-product__tab product-tab__active">1</div>
            <div class="woocommerce-product__tab">2</div>
            <div class="woocommerce-product__tab">3</div>
            <div class="woocommerce-product__tab">4</div>
            <div class="woocommerce-product__tab">5</div>
        </div>
        <div class="woocommerce-product__tabs-wrapper">
            <div class="woocommerce-product__tab-item"><?php the_field( 'characteristics' ); ?></div>
            <div class="woocommerce-product__tab-item"><?php the_field( 'complete_set' ); ?></div>
            <div class="woocommerce-product__tab-item"><?php the_field( 'review' ); ?></div>
            <div class="woocommerce-product__tab-item"><?php the_field( 'recipes' ); ?></div>
            <?php foreach ( $product_tabs as $key => $product_tab ) : ?>
                <div class="woocommerce-product__tab-item woocommerce-Tabs-panel woocommerce-Tabs-panel--<?php echo esc_attr( $key ); ?> panel entry-content wc-tab" id="tab-<?php echo esc_attr( $key ); ?>" role="tabpanel" aria-labelledby="tab-title-<?php echo esc_attr( $key ); ?>">
                    <?php
                    if ( isset( $product_tab['callback'] ) ) {
                        call_user_func( $product_tab['callback'], $key, $product_tab );
                    }
                    ?>
                </div>
            <?php endforeach; ?>
        </div>
    
        <?php do_action( 'woocommerce_product_after_tabs' ); ?>
    </div>

How should this code be changed?

<?php foreach ( $product_tabs as $key => $product_tab ) : ?>
                <div class="woocommerce-product__tab-item woocommerce-Tabs-panel woocommerce-Tabs-panel--<?php echo esc_attr( $key ); ?> panel entry-content wc-tab" id="tab-<?php echo esc_attr( $key ); ?>" role="tabpanel" aria-labelledby="tab-title-<?php echo esc_attr( $key ); ?>">
                    <?php
                    if ( isset( $product_tab['callback'] ) ) {
                        call_user_func( $product_tab['callback'], $key, $product_tab );
                    }
                    ?>
                </div>
            <?php endforeach; ?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Nesterov, 2021-08-05
@cooder

Using the woocommerce_product_tabs hook -
add to functions.php:

add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );

        function woo_remove_product_tabs( $tabs ) {

            unset( $tabs['description'] ); 
            unset( $tabs['additional_information'] ); 

            return $tabs;
        }

where in unset are the tabs to be removed. In your case, these are: description and additional_information. If you want to remove only information, leave only the line unset( $tabs['additional_information'] ).
See the documentation for this hook for more details -
https://docs.woocommerce.com/document/editing-prod...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question