Get Order items and WC_Order_Item_Product in WooCommerce 3

前端 未结 2 1178
孤城傲影
孤城傲影 2020-11-22 00:19

Reading up the changes in WooCommerce 3.0, it seems that is not possible to anymore properties from order items directly, so I would assume that the following code needs to

2条回答
  •  天涯浪人
    2020-11-22 00:58

    WC_Order_Item_Product inherits from WC_Order_Item, which has get_order_id(), so you can get the Order ID with

    $order_item->get_order_id();
    

提交回复
热议问题