在 Woocommerce 中,我在管理区域有一份报告,记录了所售产品。网站上仅售出 5 种产品,但有些产品有 1 或 2 种变体。该报告效果很好,但忽略了变化。
我需要从订购的项目中检索属性值以准确显示数据。
我该怎么做呢?
get_variation_description() 没有按照我应用它的方式工作。
我的代码:
$order = wc_get_order( $vs);
//BEGIN NEW RETRIEVE ORDER ITEMS FROM ORDER
foreach( $order->get_items() as $item_id => $item_product ){
$ods = $item_product->get_product_id(); //Get the product ID
$odqty= $item_product->get_quantity(); //Get the product QTY
$item_name = $item_product->get_name(); //Get the product NAME
$item_variation = $item_product->get_variation_description(); //NOT WORKING
}
Run Code Online (Sandbox Code Playgroud)