I was using original snippet to reorders tabs.
then realized that if I forget to put description or attributes, these tabs are empty.
Then snippet creates php error.
here is the original code and my error comment. https://gist.github.com/woogists/abb8a37f8c708d712e46ce2d02ffdc43#file-wc-reorder-tabs-php
add_filter( 'woocommerce_product_tabs', 'woo_reorder_tabs', 98 );
function woo_reorder_tabs( $tabs ) {
if ($tabs[''] !== undefined)
{
$tabs['additional_information']['priority'] = 1;
}
return $tabs;
}
then I added if empty rule and changed the code like this. but this is also create another error.
add_filter( 'woocommerce_product_tabs', 'woo_reorder_tabs', 98 );
function woo_reorder_tabs( $tabs ) {
if ($tabs[''] !== undefined)
{
$tabs['additional_information']['priority'] = 1;
}
return $tabs;
}
here is the error
PHP Warning: Use of undefined constant undefined - assumed 'undefined' (this will throw an Error in a future version of PHP) in /kunder/gaming_10908/devgam_14130/public/wp-content/plugins/code-snippets/php/snippet-ops.php(469) : eval()'d code on line 6
Do you have any suggestion?
2
Answers
This one also worked for me.
PHP doesn’t have the
undefined
constant. It is a javascript thing.Your code should be as below.