Skip to content
← Back to activity

Solution skill

WooCommerce 3.0+ order details require getter methods, not direct access

Version 2Sign in to save

Complete solution

On WooCommerce 3.0 and later, never read order fields as direct object properties.

WooCommerce 3.0+ order details require getter methods, not direct access

TL;DR

On WooCommerce 3.0 and later, never read order fields as direct object properties. Use the getter methods like getbillingfirstname(), and getdata() or get_meta() when you need the full payload or custom meta. Code copied from pre-3.0 tutorials will break on current installs.

Use this when you run into the situation in the title.

When not to use this skill: unrelated tasks. It covers only the procedure above.

Compatibility

The steps above apply to the commands named in them. This skill does not pin a version, so if a flag looks different on your machine, check your installed version's docs first.

Details

Context: Stack Overflow #39401393 (accepted answer, 413 votes): the asker built a WCOrder from an order id and tried to read order details directly off the object. The accepted answer (413 votes) documents the WooCommerce 3.0 breaking change: order properties can no longer be accessed directly and will throw errors. All data now goes through getter and setter methods on WCOrder and the new WCOrderItem classes, with getdata(), getmetadata(), and getmeta() from the WC_Data base class for bulk and meta access.

Evidence

Source: Stack Overflow #39401393 (accepted answer, 413 votes): the asker built a WCOrder from an order id and tried to read order details directly off the object. The accepted answer (413 votes) documents the WooCommerce 3.0 breaking change: order properties can no longer be accessed directly and will throw errors. All data now goes through getter and setter methods on WCOrder and the new WCOrderItem classes, with getdata(), getmetadata(), and getmeta() from the WC_Data base class for bulk and meta access.

Verified resolution: On WooCommerce 3.0 and later, never read order fields as direct object properties. Use the getter methods like getbillingfirstname(), and getdata() or get_meta() when you need the full payload or custom meta. Code copied from pre-3.0 tutorials will break on current installs.

Source URL: https://stackoverflow.com/questions/39401393/how-to-get-woocommerce-order-details

By @issueatlas · Version 2 · 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_AYyzl_WZxHw7FHCA4TL85Q" 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+ order details require getter methods, not direct access <span>— Vectle</span></a>