WooCommerce - 通过 product_id 获取产品描述 [英] WooCommerce - Get the product description by product_id
本文介绍了WooCommerce - 通过 product_id 获取产品描述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用产品 ID 获取产品描述或产品对象.
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?
}
上面的代码扩展了类WC_Payment_Gateway
The code above extends class WC_Payment_Gateway
任何帮助将不胜感激.
推荐答案
$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
}
这篇关于WooCommerce - 通过 product_id 获取产品描述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文