How To Get Order Details In Woocommerce

As a user of WooCommerce, one of your biggest responsibilities will be retrieving order information. It is essential to know how to access and extract this information to efficiently manage your e-commerce business. In this article, I will walk you through the steps of obtaining order details in WooCommerce, equipping you with the knowledge you need to optimize your operations.

Accessing the Order Object

In WooCommerce, order details are stored in an object called $order. To access this object, you can use the following code:

$order = wc_get_order( $order_id );

Here, $order_id refers to the specific order ID you want to retrieve details for. This code snippet retrieves the $order object, allowing you to extract information about the order.

Retrieving Basic Order Information

Once you have the $order object, you can access various properties to retrieve basic order information. For example, you can obtain the order’s total amount, billing details, and shipping details using the following code:

$order_total = $order->get_total();
$billing_address = $order->get_billing_address();
$shipping_address = $order->get_shipping_address();

By utilizing these methods, you can quickly retrieve essential information about the order, such as the total cost and customer addresses.

Accessing Product Details

In addition to basic order information, WooCommerce allows you to access product-specific details for each order. To retrieve product details, you can use the following code:

$items = $order->get_items();

This code retrieves an array of items in the order. To access specific details for each product, you can iterate through this array using a foreach loop. For example:

foreach ( $items as $item ) {
$product_id = $item->get_product_id();
$product_name = $item->get_name();
$product_price = $item->get_price();
// Perform operations with the product details

In this loop, you can obtain the product ID, name, and price for each item in the order. This information can be used to perform various operations, such as inventory management or generating personalized order confirmations.


Retrieving order details in WooCommerce is essential for managing your e-commerce business effectively. By accessing the $order object and utilizing its properties and methods, you can obtain basic order information, customer addresses, and product-specific details. This knowledge empowers you to streamline your operations, enhance customer service, and maintain a smooth order fulfillment process.