I am trying to display the product variation description in the order detail page and in the order email. Following this example Woocommerce: Display Product Variation Description on Cart page it worked perfectly for the cart and also for the checkout. But it seems i can't find the right way of calling it for the order page.
This
$item = $cart_item['data'];
if(!empty($item) && $item->is_type( 'variation' ) ){
echo '<dl><dd>' . $item->get_variation_description() }
is not working, as it calls for the cart item data .. And the get_post_meta as suggested here WooCommerce displaying variable description after variable price is not working either.
$_variable_description = get_post_meta( $variation->id , '_variation_description', true );
I tried to place it in either the order-details-item.php and the class-wc-order-item-meta.php, and of course the email-order-details.php
Any suggestions? Thanks!
I finally found a solution that worked here now showing the variation description on the order page and the order email.
add_filter( 'woocommerce_order_item_name', 'display_product_title_as_link', 10, 2 );
function display_product_title_as_link( $item_name, $item ) {
$_product = get_product( $item['variation_id'] ? $item['variation_id'] : $item['product_id'] );
$link = get_permalink( $_product->id );
$_var_description ='';
if ( $item['variation_id'] ) {
$_var_description = $_product->get_variation_description();
}
return '<a href="'. $link .'" rel="nofollow">'. $item_name .'</a><br>'. $_var_description ;
}
It puts the variations description right below the title, but that works for me.