如何使用产品 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 类
如有任何帮助,我们将不胜感激。
最佳答案
$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
}
关于php - WooCommerce - 通过 product_id 获取产品描述,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19763915/