1// Get $order object when you have the ID.
2$order = wc_get_order( $order_id );
3
4// Get order key.
5$order->get_order_key();
6
7// Get Order Totals $0.00
8$order->get_formatted_order_total();
9$order->get_cart_tax();
10$order->get_currency();
11$order->get_discount_tax();
12$order->get_discount_to_display();
13$order->get_discount_total();
14$order->get_fees();
15$order->get_formatted_line_subtotal();
16$order->get_shipping_tax();
17$order->get_shipping_total();
18$order->get_subtotal();
19$order->get_subtotal_to_display();
20$order->get_tax_location();
21$order->get_tax_totals();
22$order->get_taxes();
23$order->get_total();
24$order->get_total_discount();
25$order->get_total_tax();
26$order->get_total_refunded();
27$order->get_total_tax_refunded();
28$order->get_total_shipping_refunded();
29$order->get_item_count_refunded();
30$order->get_total_qty_refunded();
31$order->get_qty_refunded_for_item();
32$order->get_total_refunded_for_item();
33$order->get_tax_refunded_for_item();
34$order->get_total_tax_refunded_by_rate_id();
35$order->get_remaining_refund_amount();
36
37// Get and Loop Over Order Items
38foreach ( $order->get_items() as $item_id => $item ) {
39 $product_id = $item->get_product_id();
40 $variation_id = $item->get_variation_id();
41 $product = $item->get_product();
42 $name = $item->get_name();
43 $quantity = $item->get_quantity();
44 $subtotal = $item->get_subtotal();
45 $total = $item->get_total();
46 $tax = $item->get_subtotal_tax();
47 $taxclass = $item->get_tax_class();
48 $taxstat = $item->get_tax_status();
49 $allmeta = $item->get_meta_data();
50 $somemeta = $item->get_meta( '_whatever', true );
51 $type = $item->get_type();
52}
53
54// Other Secondary Items Stuff
55$order->get_items_key();
56$order->get_items_tax_classes();
57$order->get_item_count();
58$order->get_item_total();
59$order->get_downloadable_items();
60
61// Get Order Lines
62$order->get_line_subtotal();
63$order->get_line_tax();
64$order->get_line_total();
65
66// Get Order Shipping
67$order->get_shipping_method();
68$order->get_shipping_methods();
69$order->get_shipping_to_display();
70
71// Get Order Dates
72$order->get_date_created();
73$order->get_date_modified();
74$order->get_date_completed();
75$order->get_date_paid();
76
77// Get Order User, Billing & Shipping Addresses
78$order->get_customer_id();
79$order->get_user_id();
80$order->get_user();
81$order->get_customer_ip_address();
82$order->get_customer_user_agent();
83$order->get_created_via();
84$order->get_customer_note();
85$order->get_address_prop();
86$order->get_billing_first_name();
87$order->get_billing_last_name();
88$order->get_billing_company();
89$order->get_billing_address_1();
90$order->get_billing_address_2();
91$order->get_billing_city();
92$order->get_billing_state();
93$order->get_billing_postcode();
94$order->get_billing_country();
95$order->get_billing_email();
96$order->get_billing_phone();
97$order->get_shipping_first_name();
98$order->get_shipping_last_name();
99$order->get_shipping_company();
100$order->get_shipping_address_1();
101$order->get_shipping_address_2();
102$order->get_shipping_city();
103$order->get_shipping_state();
104$order->get_shipping_postcode();
105$order->get_shipping_country();
106$order->get_address();
107$order->get_shipping_address_map_url();
108$order->get_formatted_billing_full_name();
109$order->get_formatted_shipping_full_name();
110$order->get_formatted_billing_address();
111$order->get_formatted_shipping_address();
112
113// Get Order Payment Details
114$order->get_payment_method();
115$order->get_payment_method_title();
116$order->get_transaction_id();
117
118// Get Order URLs
119$order->get_checkout_payment_url();
120$order->get_checkout_order_received_url();
121$order->get_cancel_order_url();
122$order->get_cancel_order_url_raw();
123$order->get_cancel_endpoint();
124$order->get_view_order_url();
125$order->get_edit_order_url();
126
127// Get Order Status
128$order->get_status();
1// Get an instance of the WC_Order object
2$order = wc_get_order( $order_id );
3
4$order_data = $order->get_data(); // The Order data
5
6$order_id = $order_data['id'];
7$order_parent_id = $order_data['parent_id'];
8$order_status = $order_data['status'];
9$order_currency = $order_data['currency'];
10$order_version = $order_data['version'];
11$order_payment_method = $order_data['payment_method'];
12$order_payment_method_title = $order_data['payment_method_title'];
13$order_payment_method = $order_data['payment_method'];
14$order_payment_method = $order_data['payment_method'];
15
16## Creation and modified WC_DateTime Object date string ##
17
18// Using a formated date ( with php date() function as method)
19$order_date_created = $order_data['date_created']->date('Y-m-d H:i:s');
20$order_date_modified = $order_data['date_modified']->date('Y-m-d H:i:s');
21
22// Using a timestamp ( with php getTimestamp() function as method)
23$order_timestamp_created = $order_data['date_created']->getTimestamp();
24$order_timestamp_modified = $order_data['date_modified']->getTimestamp();
25
26$order_discount_total = $order_data['discount_total'];
27$order_discount_tax = $order_data['discount_tax'];
28$order_shipping_total = $order_data['shipping_total'];
29$order_shipping_tax = $order_data['shipping_tax'];
30$order_total = $order_data['cart_tax'];
31$order_total_tax = $order_data['total_tax'];
32$order_customer_id = $order_data['customer_id']; // ... and so on
33
34## BILLING INFORMATION:
35
36$order_billing_first_name = $order_data['billing']['first_name'];
37$order_billing_last_name = $order_data['billing']['last_name'];
38$order_billing_company = $order_data['billing']['company'];
39$order_billing_address_1 = $order_data['billing']['address_1'];
40$order_billing_address_2 = $order_data['billing']['address_2'];
41$order_billing_city = $order_data['billing']['city'];
42$order_billing_state = $order_data['billing']['state'];
43$order_billing_postcode = $order_data['billing']['postcode'];
44$order_billing_country = $order_data['billing']['country'];
45$order_billing_email = $order_data['billing']['email'];
46$order_billing_phone = $order_data['billing']['phone'];
47
48## SHIPPING INFORMATION:
49
50$order_shipping_first_name = $order_data['shipping']['first_name'];
51$order_shipping_last_name = $order_data['shipping']['last_name'];
52$order_shipping_company = $order_data['shipping']['company'];
53$order_shipping_address_1 = $order_data['shipping']['address_1'];
54$order_shipping_address_2 = $order_data['shipping']['address_2'];
55$order_shipping_city = $order_data['shipping']['city'];
56$order_shipping_state = $order_data['shipping']['state'];
57$order_shipping_postcode = $order_data['shipping']['postcode'];
58$order_shipping_country = $order_data['shipping']['country'];
1// Get an instance of the WC_Order object (same as before)
2$order = wc_get_order( $order_id );
3
4$order_id = $order->get_id(); // Get the order ID
5$parent_id = $order->get_parent_id(); // Get the parent order ID (for subscriptions…)
6
7$user_id = $order->get_user_id(); // Get the costumer ID
8$user = $order->get_user(); // Get the WP_User object
9
10$order_status = $order->get_status(); // Get the order status
11$currency = $order->get_currency(); // Get the currency used
12$payment_method = $order->get_payment_method(); // Get the payment method ID
13$payment_title = $order->get_payment_method_title(); // Get the payment method title
14$date_created = $order->get_date_created(); // Get date created (WC_DateTime object)
15$date_modified = $order->get_date_modified(); // Get date modified (WC_DateTime object)
16
17$billing_country = $order->get_billing_country(); // Customer billing country
18
19// ... and so on ...
1foreach ( $items as $item ) {
2 $product_name = $item->get_name();
3 $product_id = $item->get_product_id();
4 $product_variation_id = $item->get_variation_id();
5}