0

I am trying to add a custom tab to Woocommerce Product ; I have tried with this code snippet in functions.php :

add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
// Adds the new tab
    $tabs['desc_tab'] = array(
        'title'     => __( 'Additional Informationsss', 'woocommerce' ),
        'callback'  => 'woo_new_product_tab_content'
    );
}

function woo_new_product_tab_content() {
    // The new tab content
    echo '<p>Lorem Ipsum</p>';
}

But it is showing this error :

Notice: Function woocommerce_sort_product_tabs() expects an array as the first parameter. Defaulting to empty array

Do anyone has encountered this error before or have an idea how to deal with it ?

Thanks in advance

2
  • you are not returning anything in your filter, you should return $tabs after apending new tab array
    – silver
    Jan 20 at 9:56
  • woocommerce and other 3rd party product/plugin/theme dev support questions are offtopic here and not in this stacks scope
    – Tom J Nowell
    Feb 4 at 18:34

1 Answer 1

0

i think you most return $tabs in your woo_new_product_tab function

try this :

function woo_new_product_tab( $tabs ) {
// Adds the new tab
$tabs['desc_tab'] = array(
    'title'     => __( 'Additional Informationsss', 'woocommerce' ),
    'priority' => 10,
    'callback'  => 'woo_new_product_tab_content',
);
return $tabs;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.