Get Order items and WC_Order_Item_Product in WooCommerce 3

Viewed 71273

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 be changed, since it is spitting out an error:

$order_item_id = 15;
$order_item = new WC_Order_Item_Product($order_item_id);
$return = $order_item->get_id() ? $order_item : false;

But, embarrassingly, I'm not sure how to change this code to use the correct new getter and setter functions in the newest version of this class, which no longer has a construct. How to do this properly? I don't see any get function on getting the order item in the same way as the above.
https://docs.woocommerce.com/wc-apidocs/class-WC_Order_Item_Product.html

Maybe I am overlooking something here?

2 Answers
Related