Add product short description after product title in WooCommerce order completed notification

77 Views Asked by At

I would like to add product short description after product title in woocommerce order completed email. What would be the correct snippet?

I tryid snippet here WooCommerce - Add product Short Description to completed order email but it doesnt work, php snippet plugin says: Snippet automatically deactivated due to an error on line 5: Cannot redeclare function woo_completed_order_email_notification.

1

There are 1 best solutions below

1
LoicTheAztec On

Try the following revisited code (removing before all previous related code):

// Displaying product short description on completed order email notifications
add_action( 'woocommerce_order_item_meta_end', 'product_short_description_in_completed_order_notification', 10, 4 );
function product_short_description_in_completed_order_notification( $item_id, $item, $order = null, $plain_text = false ){
    // Only for "Customer Completed Order email notification"
    if( ! is_wc_endpoint_url() && is_a($order, 'WC_Order') && $order->has_status('completed') ) {
        $product = wc_get_product( $item->get_product_id() );

        // Display the Product short description
        if ( $short_description = $product->get_short_description() ) {
            echo '<div class="product-description"><p>' . $short_description . '</p></div>';
        }
    }
}

Code goes in functions.php file of your child theme (or in a plugin). Tested and works.

Related: Add the product description to WooCommerce email notifications