WooCommerce get order detail

Today we talk about WooCommerce or WordPress get order detail programmatically. In this tutorial, We focus on how to get order data by order id. You need to first get an order id. In this example, we focus on getting order billing information, order shipping information, other order details like order status, order payment method, order shipping method, and order tax information.

Let’s start with our example.

$orderId = 1;
$orderData =   wc_get_order( $orderId );
echo $order_id = $orderData->get_id();
echo $orderParentId = $orderData->get_parent_id();
echo $orderStatus = $orderData->get_status();
echo $orderCurrency = $orderData->get_currency();
echo $orderVersion = $orderData->get_version();

// Order payment details
echo $orderPaymentMethod = $orderData->get_payment_method();
echo $orderPaymentMethodTitle = $orderData->get_payment_method_title();

//Order Shipping details
$orderData->get_shipping_methods();

// Order date information
echo $orderDateCreated = $orderData->get_date_created()->date('Y-m-d H:i:s');
echo $orderDateModified = $orderData->get_date_modified()->date('Y-m-d H:i:s');


echo $orderDiscountTotal = $orderData->get_discount_total();
echo $orderDiscountTax = $orderData->get_discount_tax();
echo $orderShippingTotal = $orderData->get_shipping_total();
echo $orderShippingTax = $orderData->get_shipping_tax();
echo $orderTotal = $orderData->get_total();
echo $orderTotalTax = $orderData->get_total_tax();

//Order Billing Information:

echo $orderBillingFirstName = $orderData->get_billing_first_name();
echo $orderBillingLastName = $orderData->get_billing_last_name();
echo $orderBillingCompany = $orderData->get_billing_company();
echo $orderBillingAddress1 = $orderData->get_billing_address_1();
echo $orderBillingAddress2 = $orderData->get_billing_address_2();
echo $orderBillingCity = $orderData->get_billing_city();
echo $orderBillingState = $orderData->get_billing_state();
echo $orderBillingPostcode = $orderData->get_billing_postcode();
echo $orderBillingCountry = $orderData->get_billing_country();
echo $orderBillingEmail = $orderData->get_billing_email();
echo $orderBillingPhone = $orderData->get_billing_phone();

//Order Shipping Information:
echo $orderShippingFirstName = $orderData->get_shipping_first_name();;
echo $orderShippingLastName = $orderData->get_shipping_last_name();
echo $orderShippingCompany = $orderData->get_shipping_company();
echo $orderShippingAddress1 = $orderData->get_shipping_address_1();
echo $orderShippingAddress2 = $orderData->get_shipping_address_2();
echo $orderShippingCity = $orderData->get_shipping_city();
echo $orderShippingState = $orderData->get_shipping_state();
echo $orderShippingPostcode = $orderData->get_shipping_postcode();
echo $orderShippingCountry = $orderData->get_shipping_country();

Qaisar Satti

Hi, I'm Qaisar Satti! I've been a developer for over 20 years, and now I love sharing what I've learned through tutorials and guides. Whether you're working with Magento, PrestaShop, or WooCommerce, my goal is to make your development journey a bit easier and more fun. When I'm not coding or writing, you can find me exploring new tech trends and hanging out with the amazing developer community. Thanks for stopping by, and happy coding!