Comprehensive Guide to WooCommerce Order Class Get Methods: Retrieving Order Data the Object-Oriented Way

When developing WooCommerce plugins or interacting with third-party systems, we often need to retrieve WooCommerce order data. The WooCommerce WC_Order class provides a comprehensive set of methods to access various types of order information. Below is a detailed list of these methods.

If you need to create or update order data, most of the get methods listed below have corresponding set methods, making it very convenient for developers.

Basic Order Data

  • get_id() – Get the Order ID
  • get_parent_id() – Get the Parent Order ID (often used for refunds)
  • get_status() – Get the order status
  • get_currency() – Get the currency used in the order
  • get_version() – Get the WooCommerce version used when the order was created
  • get_prices_include_tax() – Check if order prices include tax
  • get_date_created() – Get the order creation date
  • get_date_modified() – Get the order last modified date
  • get_discount_total() – Get the total discount amount
  • get_discount_tax() – Get the total discount tax amount
  • get_shipping_total() – Get the total shipping cost
  • get_shipping_tax() – Get the total shipping tax
  • get_cart_tax() – Get the total cart tax
  • get_total() – Get the order total amount
  • get_total_tax() – Get the total tax amount for the order

Order Items and Totals

  • get_items() – Get all items in the order (products, shipping, taxes, etc.)
  • get_items_key() – Get the key used for order items
  • get_item_count() – Get the number of items in the order
  • get_shipping_methods() – Get all shipping methods used in the order
  • get_address_prop() – Get address properties (billing or shipping)
  • get_billing_first_name() – Get billing first name
  • get_billing_last_name() – Get billing last name
  • get_billing_company() – Get billing company name
  • get_billing_address_1() – Get billing address line 1
  • get_billing_address_2() – Get billing address line 2
  • get_billing_city() – Get billing city
  • get_billing_state() – Get billing state
  • get_billing_postcode() – Get billing postcode
  • get_billing_country() – Get billing country
  • get_billing_email() – Get billing email address
  • get_billing_phone() – Get billing phone number
  • get_shipping_first_name() – Get shipping first name
  • get_shipping_last_name() – Get shipping last name
  • get_shipping_company() – Get shipping company
  • get_shipping_address_1() – Get shipping address line 1
  • get_shipping_address_2() – Get shipping address line 2
  • get_shipping_city() – Get shipping city
  • get_shipping_state() – Get shipping state
  • get_shipping_postcode() – Get shipping postcode
  • get_shipping_country() – Get shipping country
  • get_payment_method() – Get the payment method ID
  • get_payment_method_title() – Get the title of the payment method
  • get_transaction_id() – Get the payment transaction ID
  • get_date_paid() – Get the date the order was paid
  • get_total_discount() – Get the total discount amount, optionally including or excluding tax
  • get_user() – Get the user object for the order; returns false for guests
  • get_user_id() – Get the user ID; returns 0 for guests
  • get_customer_order_notes() – Get customer-related order notes
  • get_customer_note() – Get the note provided by the customer during checkout
  • get_customer_id() – Get the customer ID
  • get_customer_ip_address() – Get the customer’s IP address at the time of order
  • get_customer_user_agent() – Get the customer’s browser user agent
  • get_reason() – Get the reason for a refund
  • get_refunds() – Get refund items
  • get_refunded_by() – Get the ID of the user who performed the refund
  • get_refunded_payment() – Get the refund payment method
  • get_remaining_refund_items() – Get remaining items eligible for refund
  • get_remaining_refund_amount() – Get the remaining amount eligible for refund
  • get_formatted_refund_amount() – Get the formatted refund amount
  • get_qty_refunded_for_item() – Get the quantity refunded for a specific item
  • get_tax_refunded_for_item() – Get the tax refunded for a specific item
  • get_total_refunded_for_item() – Get the total amount refunded for a specific item
  • get_checkout_payment_url() – Get the checkout payment URL
  • get_cancel_order_url() – Get the order cancellation URL
  • get_edit_order_url() – Get the URL to edit the order
  • get_view_order_url() – Get the order view URL
  • get_download_url() – Get the download URL for digital products
  • get_shipping_address_map_url() – Get the shipping address map URL
  • get_checkout_order_received_url() – Get the ‘Order Received’ URL after successful checkout

Retrieving Custom Field Data

  • get_meta() – Retrieve specific custom field data
  • get_meta_data() – Get all custom field data

In addition to the methods listed above, some developers may still use get_post or get_post_meta to retrieve order data. While this works when WooCommerce stores orders as custom post types, it will fail if High-Performance Order Storage (HPOS) is enabled. Therefore, it is highly recommended to use the WC_Order class for custom development. This approach ensures forward compatibility and reduces maintenance as WooCommerce continues to evolve its data structures.

The list above was updated for WooCommerce 7.6. We will continue to update this list as new versions are released. If we missed any methods, please let us know in the comments!

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *