WooCommerce - Get the product description by product_id

Vincent Panugaling picture Vincent Panugaling · Nov 4, 2013 · Viewed 48k times · Source

How can I get the product description or the product object using product ID.

$order = new WC_Order($order_id);

foreach ($order->get_items() as $item) {
    $product_description = get_the_product_description($item['product_id']); // is there any method can I use to fetch the product description?
}

The code above extends class WC_Payment_Gateway

Any help would be greatly appreciated.

Answer

Vincent Panugaling picture Vincent Panugaling · Nov 14, 2013
$order = new WC_Order($order_id);

foreach ($order->get_items() as $item)
{
    $product_description = get_post($item['product_id'])->post_content; // I used wordpress built-in functions to get the product object 
}