• Resolved sgucci1

    (@sgucci1)


    Is it possible to hide (not display) a custom tab on a product pae if there is no info available. For instance, we want to add a video tab to product pages, but not all products will have a video. For the products with no video, I would like the tab to not display.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor MD Imran Khan

    (@imranwpb)

    Hi @sgucci1,

    Hope you are doing good. Thanks for showing interest in this plugin.

    If this is the only purpose, you don’t need this plugin. You can do it by adding a few line of PHP code. All you have to check if the video meta value is present then show a custom with that video in the tab content.
    You can find more details how it can be done here in our blog: https://wpbean.com/add-edit-customize-woocommerce-product-tabs/

    Here is an example of it, Just add your video meta key in this code:

    add_filter( 'woocommerce_product_tabs', function($tabs){
    global $product;
    $id = $product->get_id();
    $video = get_post_meta( $id, 'your_video_meta_key_here', true );

    if(isset($video) && '' != $video){
    $tabs['custom_video_tab'] = array(
    'title' => 'Video',
    'priority' => 30,
    'callback' => 'wpb_product_custom_video_tab_content'
    );
    }

    return $tabs;
    } );

    function wpb_product_custom_video_tab_content() {
    global $product;
    $id = $product->get_id();
    $video = get_post_meta( $id, 'your_video_meta_key_here', true );

    echo $video;
    }

    BTW with the premium version, You can add custom tabs only for selected tabs and show product custom meta without adding any custom code.

    Thank You

    Thread Starter sgucci1

    (@sgucci1)

    Thanks for the quick response.

    Actually there are other uses, this was just one example.

    Basically we do not want a custom tab to display if the tab field is empty.  Whether it is a video tab, more info tab, replacement products tab, faq, etc.

    Are you saying your premium version will do this?

    Plugin Contributor MD Imran Khan

    (@imranwpb)

    In the premium version you can add custom tabs in the product edit page. This tab will be visible only for that particular product. You can add any type content including shortcodes in the tab editor.

    So you don’t need any custom meta fields here. You can add your video, FAQ, info, etc. content directly in the tab content editor.
    If you want to try it, please send me an email using this form: https://wpbean.com/support

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Hide tabe with empty fields’ is closed to new replies.