As we know that, WooCommerce is the most popular platform for eCommerce solutions, and it already has by default templates of each page with the default template design.
So, sometimes we want to change the design of the template with our custom template and in that template, we need order details to show as per custom design.
Let’s get started.
Get WooCommerce Order Details
We have to send in the custom email body content. So there, we have to use the WC_Order object to get WooCommerce order details.
We can also use the wc_get_orders(), this is function to get the order object and get the order details on certain parameter.
So, we see how to get WooCoomerce order details with the help of getter method. You can check more method here.
If you want to get and access the protected data of the order object then, you can use the
It is the same as we did above with the instance of the
$order object. E.g:
It will return the data as an associative array and we can use this array with key=>pair value.
Let’s see the example.
With the get_data() function you can use order data as a array properties for get WooCommerce order details.
You can also loop the order items with
get_items() function, if you have multiple items in one order.
See the simple example to understand this.
Here, we loop the order items and get the value with getter method, as we used in above.
So in this article we work with:
I hope you understand! how to get WooCommerce order details and use it?