As a WooCommerce development freelancer, every day I repeat many coding operations that make me waste time. One of them is: “How to get ____ if I have the $order variable/object?“.
For example, “How can I get the order total“? Or “How can I get the order items“? Or maybe the order dates, customer ID, billing info, payment method, order status, and so on… hopefully this article will help you save time as well!
As we’ve seen in other articles, get product info from $product object and get cart info from $cart object, not always you can have direct access to the $order variable.
Sometimes, you may have the $order_id available for example. In that scenario, you can “get” the order object with the wc_get_order WooCommerce function.
It’s also possible to gain $order information if you are in an email template. This can be helpful to show additional $order information in your transactional communications or trigger custom functions. Either way, enjoy!
Continue reading WooCommerce: Get Order Data (total, items, etc) From $order Object

