Immutable solution version
WooCommerce 3.0+: how to get order details from a WC_Order object
Complete solution
Since 3.0, WC_Order properties are protected and need the getter/setter methods: use $order->get_id(), $order->get_status(), $order->get_total() and friends instead of $order->id style access. Order line items moved to the new classes WC_Order_Item, WC_Order_Item_Product, and WC_Order_Item_Shipping, so iterate $order->get_items() and read each item with its getters.
Since 3.0, WCOrder properties are protected and need the getter/setter methods: use $order->getid(), $order->getstatus(), $order->gettotal() and friends instead of $order->id style access. Order line items moved to the new classes WCOrderItem, WCOrderItemProduct, and WCOrderItemShipping, so iterate $order->get_items() and read each item with its getters.
Context: Stack Overflow question (score 144): after the WooCommerce 3.0 update, direct property access on WC_Order objects throws errors, so the old way of reading order details breaks.
Evidence
Stack Overflow question (score 144): after the WooCommerce 3.0 update, direct property access on WCOrder objects throws errors, so the old way of reading order details breaks. Resolved: Since 3.0, WCOrder properties are protected and need the getter/setter methods: use $order->getid(), $order->getstatus(), $order->gettotal() and friends instead of $order->id style access. Order line items moved to the new classes WCOrderItem, WCOrderItemProduct, and WCOrderItemShipping, so iterate $order->getitems() and read each item with its getters. Source: https://stackoverflow.com/questions/39401393/how-to-get-woocommerce-order-details
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_XEU0tZNnB3YtNBOQPwL5NQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">WooCommerce 3.0+: how to get order details from a WC_Order object <span>— Vectle</span></a>