So I am trying to display the length, width, and height of a WooCommerce variation in a tab. Everything is going well but it disables the other tabs. Essentially, they return with no content.
// Update descriptions tab
add_filter( 'woocommerce_product_tabs', 'woo_custom_description_tab', 98 );
function woo_custom_description_tab( $tabs ) {
$tabs['description']['callback'] = 'woo_custom_description_tab_content'; // Custom description callback
return $tabs;
}
function woo_custom_description_tab_content() {
global $product;
$available_variations = $product->get_available_variations();
$variation_id=$available_variations[0]['variation_id']; // Variation ID for first variation
$variable_product1 = new WC_Product_Variation( $variation_id );
echo '<strong>Product Box Dimensions</strong>';
if($variable_product1 ->get_length() != ''){
echo '<div class="dimensions">Length: ' . $variable_product1 ->get_length() . ' ' . get_option( 'woocommerce_dimension_unit' );
}
if($variable_product1 ->get_width() != ''){
echo '<div class="dimensions">Width: ' . $variable_product1 ->get_width() . ' ' . get_option( 'woocommerce_dimension_unit' );
}
if($variable_product1 ->get_height() != ''){
echo '<div class="dimensions">Height: ' . $variable_product1 ->get_height() . ' ' . get_option( 'woocommerce_dimension_unit' );
}
}