Woo Checkout – How to get WooCommerce order details

This snippet is for Woocommerce Update 3.0+

This snippet shows you how to get Woocommerce order details for a individual order by ID. You can find the order ID in the dashboard.

If you need help implementing this we can help please use of submit a woocommerce job form.

## Get Your Order ID
$order_id = 232323 // Change to your order Id
$order = wc_get_order( $order_id );

## Get Item Details
$product_name = $item_data['name'];
$product_id   = $item_data['product_id'];
$variation_id = $item_data['variation_id'];
$quantity     = $item_data['quantity'];
$tax_class    = $item_data['tax_class'];
$line_subtotal     = $item_data['subtotal'];
$line_subtotal_tax = $item_data['subtotal_tax'];
$line_total        = $item_data['total'];
$line_total_tax    = $item_data['total_tax'];

## Get Customer Details
$userId = $order->get_customer_id();
$user = $order->get_user();

## Get Order Billing Details in Array Values
$order_billing_first_name = $order_data['billing']['first_name'];
$order_billing_last_name = $order_data['billing']['last_name'];
$order_billing_email = $order_data['billing']['email'];
$order_billing_phone = $order_data['billing']['phone'];
$order_billing_company = $order_data['billing']['company'];
$order_billing_address_1 = $order_data['billing']['address_1'];
$order_billing_address_2 = $order_data['billing']['address_2'];
$order_billing_city = $order_data['billing']['city'];
$order_billing_state = $order_data['billing']['state'];
$order_billing_postcode = $order_data['billing']['postcode'];
$order_billing_country = $order_data['billing']['country'];

## Get Order Shipping Details
$order_shipping_first_name = $order_data['shipping']['first_name'];
$order_shipping_last_name = $order_data['shipping']['last_name'];
$order_shipping_company = $order_data['shipping']['company'];
$order_shipping_address_1 = $order_data['shipping']['address_1'];
$order_shipping_address_2 = $order_data['shipping']['address_2'];
$order_shipping_city = $order_data['shipping']['city'];
$order_shipping_state = $order_data['shipping']['state'];
$order_shipping_postcode = $order_data['shipping']['postcode'];
$order_shipping_country = $order_data['shipping']['country'];

View on snippet on GitHub.

Checkout our other Woocommerce Snippets.

NEED HELP?

If you are struggling to implement the SVG snippet then we can help from £9.99 – use our contact form below and we will get straight back to you!

HELP ME IMPLEMENT THIS SNIPPET

Leave a comment

Shares