I'm trying to display my product variation description in my Cart. I have tried inserting this code in the cart.php
template:
if ( $_product->is_type( 'variation' ) ) {echo $_product->get_variation_description();}
By following this documentation https://docs.woocommerce.com/document/template-structure/
But it's still not showing up.
Not sure what I'm doing wrong here.
Can anyone help on this?
Thanks
This will work for WC 3.0
Since WooCommerce 3,
get_variation_description()
is now deprecated and replaced by theWC_Product
methodget_description()
.woocommerce_cart_item_name
hook, without editing any template.Case 1 - using
woocommerce_cart_item_name
hook:In this case the description is just displayed between the title and the variation attributes values.
This code goes in function.php file of your active child theme (or theme) or also in any plugin file.
Case 2 - Using
cart/cart.php
template (Update as per your comment).You can chose where you want to display this description (2 choices):
So you will insert this code on cart.php template around line 86 or 90 depending on your choice:
All the code is tested and is fully functional
You can get it via global variable
$woocommerce
also-I already check it.