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