i merged the description and the additional information tab. the additional information content is shown in the description tabs.
it works fine, but the content from additional information is shown above the description content. i cant figure out why...
add_filter( 'the_content', 'customizing_woocommerce_description' );
function customizing_woocommerce_description( $content ) {
// get attributes
global $product;
$attributes = do_action( 'woocommerce_product_additional_information', $product );
// Only for single product pages (woocommerce)
if ( is_product() ) {
// The custom content
$custom_content = $attributes;
// Inserting the custom content at the end
$content .= $custom_content;
}
return $content;
}
// Manipulating product tabs
add_filter('woocommerce_product_tabs', 'change_product_tab', 98);
function change_product_tab($tabs){
global $product;
// Remove tabs
unset($tabs['additional_information']);
return $tabs;
}
i merged the description and the additional information tab. the additional information content is shown in the description tabs.
it works fine, but the content from additional information is shown above the description content. i cant figure out why...
add_filter( 'the_content', 'customizing_woocommerce_description' );
function customizing_woocommerce_description( $content ) {
// get attributes
global $product;
$attributes = do_action( 'woocommerce_product_additional_information', $product );
// Only for single product pages (woocommerce)
if ( is_product() ) {
// The custom content
$custom_content = $attributes;
// Inserting the custom content at the end
$content .= $custom_content;
}
return $content;
}
// Manipulating product tabs
add_filter('woocommerce_product_tabs', 'change_product_tab', 98);
function change_product_tab($tabs){
global $product;
// Remove tabs
unset($tabs['additional_information']);
return $tabs;
}
the content from additional information is shown above the description content
Because the following code calls wc_display_product_attributes()
which displays the default content for the additional information tab:
do_action( 'woocommerce_product_additional_information', $product );
To fix it, you can turn on output buffering, run the do_action()
and then get the output using ob_get_clean()
:
function customizing_woocommerce_description( $content ) {
// get attributes
global $product;
// Only for single product pages (woocommerce)
if ( is_product() ) {
// The custom content
ob_start();
do_action( 'woocommerce_product_additional_information', $product );
$custom_content = ob_get_clean();
// Inserting the custom content at the end
$content .= $custom_content;
}
return $content;
}