You can display the product variation description anywhere on your single product page using PHP code with javascript or pure PHP code.
Using PHP code if you have the variation id like this :
add_action( 'woocommerce_before_single_product_summary', 'variable_product_description_by_id' );
function variable_product_description_by_id() {
global $product;
$variation = wc_get_product( '14803' );
if ( ! $product->is_type( 'variable' ) AND ! $variation )
return;
echo $variation->get_description();
}
Or using Javascript on variation selection like this :
Get All Variation Descriptions
You can also use the code from the download folder to get all product variation descriptions using data from the $variation and $variation_ids.
add_action( 'woocommerce_before_single_product_summary', 'get_variable_product_descriptions_by_id' );
function get_variable_product_descriptions_by_id() {
global $product;
$variation_ids = $product->get_children();
if ( empty( $variation_ids ) ) {
return;
}
foreach ( $variation_ids as $variation_id ):
$variation = wc_get_product( $variation_id );
$description = $variation->get_description();
echo $description;
endforeach;
}
Reviews
There are no reviews yet.