Im coding a tab for woocommerce that shows on specific products (kimonos). the code I have sucessfully shows the tab on the kimono product page, but gives a critical error for non kimono items.
function FAQ_kim( $tabs ) {
global $product;
if ( ! $product ) {
return;
}
$product_id = $product->get_id();
if ( ! has_term( 'kimonos-and-gowns', 'product_cat', $product_id ) ) {
return;
}
$tabs['FAQ'] = array(
'title' => 'FAQ',
'priority' => 40,
'callback' => 'faq_content');
return $tabs;
}
function faq_content() { echo 'test';}
add_filter( 'woocommerce_product_tabs', 'FAQ_kim' );
when i debug the code it tells me that:
PHP Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, null given in /var/www/html/wp-content/themes/goldish/includes/woocommerce/woocommerce.php:1374
How do i get around this, and not have the tab display on non kimono products?
Thanks