I am using the 2nd code snippet from Add product description to cart items in Woocommerce answer and added it to my function.php file to display the product description in the WooCommerce cart. It works great but within my product description is a shortcode from this plugin https://wordpress.org/plugins/simple-divi-shortcode/ and it does not display in the cart correctly. The shortcode [showmodule id="261"] is displayed instead.
You need simply to embed the product descition in WordPress do_shortcode()
function like:
add_filter( 'woocommerce_cart_item_name', 'customizing_cart_item_data', 10, 3);
function customizing_cart_item_data( $item_name, $cart_item, $cart_item_key ) {
// The label
$label = __( 'Description', 'woocommerce' );
// Get the product description
$description = $cart_item['data']->get_description();
// For product variations when description is empty
if( $cart_item['data']->is_type('variation') && empty( $description ) ){
// Get the parent variable product object
$product = wc_get_product( $cart_item['data']->get_parent_id() );
// Get the variable product description
$description = $product->get_description();
}
if( ! empty( $description ) ){
$item_name .= '<p class="item-description" style="margin:12px 0 0;">
<strong>'.$label.'</strong>: <br>' . do_shortcode( $description ) . '
</p>';
}
return $item_name;
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.