I'm struggling to find a simple solution to this problem I'm having with One-page-checkout plugin for Woocommerce.
My client would like to add the product description next to the product title in cart items.
Any thoughts on how I can manipulate the code to show the description?
This is what I have actually:

I would think that this plugin would just be hiding the description somewhere but I can't locate it anywhere in the code.
There is 2 ways to do it (making work for products and product variations):
1). With custom function hooked in woocommerce_get_item_data action hook (The best way):
add_filter( 'woocommerce_get_item_data', 'customizing_cart_item_data', 10, 2 );
function customizing_cart_item_data( $cart_data, $cart_item ) {
$description = $cart_item['data']->get_description(); // Get the product description
// For product variations when description is empty
if( $cart_item['variation_id'] > 0 && empty( $description ) ){
// Get the parent variable product object
$parent_product = wc_get_product( $cart_item['product_id'] );
// Get the variable product description
$description = $parent_product->get_description();
}
// If product or variation description exists we display it
if( ! empty( $description ) ){
$cart_data[] = array(
'key' => __( 'Description', 'woocommerce' ),
'value' => $description,
'display' => $description,
);
}
return $cart_data;
}
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
… or …
2). With custom function hooked in woocommerce_cart_item_name filter hook:
WooCommerce: Display also product variation description on cart items
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With