Get “order” object/details from Thank You page of WooCommerce (WordPress)

It’s been a long while since I last posted anything related to coding. I haven’t really stopped, but from Android app development, I switched back to PHP. Life has become occupied with other things, but when I do code, it’s in WordPress with WooCommerce. It’s for my online shop.

In my opinion, WordPress is not the most pleasant platform to use if you’re a developer (after years of MVC coding for Android I find WordPress quite messy), but it’s what I already know. I don’t have time to learn another.

Today’s code snippet is for customizing the Thank You page (post-checkout) by retrieving the “order” object.

The $order_id is what we’ll start with. Then we get the order object with the help of the wc_get_order($order_id) method. Once you’re able to successfully call the order object, you may use its methods such as get_billing_first_name() to get the order details.

You may refer to the WC_Order class page for a list of available methods.

I originally got this code from Order Received (Thank you) page in WooCommerce and modified it to suit my needs. Check his blog out, as he has many helpful posts on how to customize WooCommerce!

Related Posts:

Posts that may be related to "Get “order” object/details from Thank You page of WooCommerce (WordPress)":

Catzie

A Filipino programmer with a variety of interests such as baking, singing, making up silly song/rap lyrics, K-pop, drawing, creating unique dessert flavors, obsessing about finding out how some things works, board games, anime, video games, and forgetting things that usually go in her long list of interests. Running small-time online dessert shops Cookies PH and Catzie's Cakery.

Leave a Reply

Your email address will not be published. Required fields are marked *