WooCommerce Code Reference

Search results

WC_Order extends WC_Abstract_Order

Order Class.

These are regular WooCommerce orders, which extend the abstract order class.

Table of Contents

$status_transition Stores data about status changes so relevant hooks can be fired. bool|array
$data Order Data array. This is the core order data exposed in APIs since 3.0.0. array
$data Core data for this object. Name value pairs (name + default value). array
$items Order items will be stored here, sometimes before they persist in the DB. array
$items_to_delete Order items that need deleting are stored here. array
$cache_group Stores meta in cache for future reads. string
$data_store_name Which data store to load. string
$object_type This is the name of this object type. string
$id ID for this object. int
$changes Core data changes for this object. array
$object_read This is false until the object is read from the DB. bool
$extra_data Extra data for this object. Name value pairs (name + default value). array
$default_data Set to _data on construct so we can track and reset data if needed. array
$data_store Contains a reference to the data store for this class. object
$meta_data Stores additional meta data. array
payment_complete() When a payment is complete this function is called. bool
get_formatted_order_total() Gets order total - formatted for display. string
save() Save data to the database. int
handle_exception() Log an error about this order is exception is encountered. mixed
set_status() Set order status. array
maybe_set_date_paid() Maybe set date paid. mixed
maybe_set_date_completed() Maybe set date completed. mixed
update_status() Updates status of order immediately. bool
status_transition() Handle the status transition. mixed
get_base_data() Get basic order data in array format. array
get_data() Get all class data in array format. array
get_changes() Expands the shipping and billing information in the changes array. mixed
get_order_number() Gets the order number for display (by default, order ID). string
get_order_key() Get order key. string
get_customer_id() Get customer_id. int
get_user_id() Alias for get_customer_id(). int
get_user() Get the user associated with the order. False for guests. WP_User|false
get_address_prop() Gets a prop for a getter method. mixed
get_billing_first_name() Get billing first name. string
get_billing_last_name() Get billing last name. string
get_billing_company() Get billing company. string
get_billing_address_1() Get billing address line 1. string
get_billing_address_2() Get billing address line 2. string
get_billing_city() Get billing city. string
get_billing_state() Get billing state. string
get_billing_postcode() Get billing postcode. string
get_billing_country() Get billing country. string
get_billing_email() Get billing email. string
get_billing_phone() Get billing phone. string
get_shipping_first_name() Get shipping first name. string
get_shipping_last_name() Get shipping_last_name. string
get_shipping_company() Get shipping company. string
get_shipping_address_1() Get shipping address line 1. string
get_shipping_address_2() Get shipping address line 2. string
get_shipping_city() Get shipping city. string
get_shipping_state() Get shipping state. string
get_shipping_postcode() Get shipping postcode. string
get_shipping_country() Get shipping country. string
get_payment_method() Get the payment method. string
get_payment_method_title() Get payment method title. string
get_transaction_id() Get transaction d. string
get_customer_ip_address() Get customer ip address. string
get_customer_user_agent() Get customer user agent. string
get_created_via() Get created via. string
get_customer_note() Get customer note. string
get_date_completed() Get date completed. WC_DateTime|null
get_date_paid() Get date paid. WC_DateTime|null
get_cart_hash() Get cart hash. string
get_address() Returns the requested address in raw, non-formatted way. array
get_shipping_address_map_url() Get a formatted shipping address for the order. string
get_formatted_billing_full_name() Get a formatted billing full name. string
get_formatted_shipping_full_name() Get a formatted shipping full name. string
get_formatted_billing_address() Get a formatted billing address for the order. string
get_formatted_shipping_address() Get a formatted shipping address for the order. string
has_billing_address() Returns true if the order has a billing address. bool
has_shipping_address() Returns true if the order has a shipping address. bool
set_address_prop() Sets a prop for a setter method. mixed
set_order_key() Set order key. mixed
set_customer_id() Set customer id. mixed
set_billing_first_name() Set billing first name. mixed
set_billing_last_name() Set billing last name. mixed
set_billing_company() Set billing company. mixed
set_billing_address_1() Set billing address line 1. mixed
set_billing_address_2() Set billing address line 2. mixed
set_billing_city() Set billing city. mixed
set_billing_state() Set billing state. mixed
set_billing_postcode() Set billing postcode. mixed
set_billing_country() Set billing country. mixed
maybe_set_user_billing_email() Maybe set empty billing email to that of the user who owns the order. mixed
set_billing_email() Set billing email. mixed
set_billing_phone() Set billing phone. mixed
set_shipping_first_name() Set shipping first name. mixed
set_shipping_last_name() Set shipping last name. mixed
set_shipping_company() Set shipping company. mixed
set_shipping_address_1() Set shipping address line 1. mixed
set_shipping_address_2() Set shipping address line 2. mixed
set_shipping_city() Set shipping city. mixed
set_shipping_state() Set shipping state. mixed
set_shipping_postcode() Set shipping postcode. mixed
set_shipping_country() Set shipping country. mixed
set_payment_method() Set the payment method. mixed
set_payment_method_title() Set payment method title. mixed
set_transaction_id() Set transaction id. mixed
set_customer_ip_address() Set customer ip address. mixed
set_customer_user_agent() Set customer user agent. mixed
set_created_via() Set created via. mixed
set_customer_note() Set customer note. mixed
set_date_completed() Set date completed. mixed
set_date_paid() Set date paid. mixed
set_cart_hash() Set cart hash. mixed
key_is_valid() Check if an order key is valid. bool
has_cart_hash() See if order matches cart_hash. bool
is_editable() Checks if an order can be edited, specifically for use on the Edit Order screen. bool
is_paid() Returns if an order has been paid for based on the order status. bool
is_download_permitted() Checks if product download is permitted. bool
needs_shipping_address() Checks if an order needs display the shipping address, based on shipping method. bool
has_downloadable_item() Returns true if the order contains a downloadable product. bool
get_downloadable_items() Get downloads from all line items for this order. array
needs_payment() Checks if an order needs payment, based on status and order total. bool
needs_processing() See if the order needs processing before it can be completed. bool
get_checkout_payment_url() Generates a URL so that a customer can pay for their (unpaid - pending) order. Pass 'true' for the checkout version which doesn't offer gateway choices. string
get_checkout_order_received_url() Generates a URL for the thanks page (order received). string
get_cancel_order_url() Generates a URL so that a customer can cancel their (unpaid - pending) order. string
get_cancel_order_url_raw() Generates a raw (unescaped) cancel-order URL for use by payment gateways. string
get_cancel_endpoint() Helper method to return the cancel endpoint. string
get_view_order_url() Generates a URL to view an order from the my account page. string
get_edit_order_url() Get's the URL to edit the order in the backend. string
add_order_note() Adds a note (comment) to the order. Order must exist. int
add_status_transition_note() Add an order note for status transition int
get_customer_order_notes() List order notes (public) for the customer. array
get_refunds() Get order refunds. array
get_total_refunded() Get amount already refunded. string
get_total_tax_refunded() Get the total tax refunded. float
get_total_shipping_refunded() Get the total shipping refunded. float
get_item_count_refunded() Gets the count of order items of a certain type that have been refunded. string
get_total_qty_refunded() Get the total number of items refunded. int
get_qty_refunded_for_item() Get the refunded amount for a line item. int
get_total_refunded_for_item() Get the refunded amount for a line item. int
get_tax_refunded_for_item() Get the refunded tax amount for a line item. float
get_total_tax_refunded_by_rate_id() Get total tax refunded by rate ID. float
get_remaining_refund_amount() How much money is left to refund? string
get_remaining_refund_items() How many items are left to refund? int
add_order_item_totals_payment_method_row() Add total row for the payment method. mixed
add_order_item_totals_refund_rows() Add total row for refunds. mixed
get_order_item_totals() Get totals for display on pages and in emails. array
is_created_via() Check if order has been created via admin, checkout, or in another way. bool
__construct() Default constructor. mixed
get_type() Get internal type. string
get_data() Returns all data for this object. array
save() Save should create or update based on object existence. int
handle_exception() Log an error about this order is exception is encountered. mixed
save_items() Save all order items which are part of this order. mixed
get_parent_id() Get parent order ID. int
get_currency() Gets order currency. string
get_version() Get order_version. string
get_prices_include_tax() Get prices_include_tax. bool
get_date_created() Get date_created. WC_DateTime|null
get_date_modified() Get date_modified. WC_DateTime|null
get_status() Return the order statuses without wc- internal prefix. string
get_discount_total() Get discount_total. string
get_discount_tax() Get discount_tax. string
get_shipping_total() Get shipping_total. string
get_shipping_tax() Get shipping_tax. string
get_cart_tax() Gets cart tax amount. float
get_total() Gets order grand total. incl. taxes. Used in gateways. float
get_total_tax() Get total tax amount. Alias for get_order_tax(). float
get_total_discount() Gets the total discount amount. float
get_subtotal() Gets order subtotal. float
get_tax_totals() Get taxes, merged by code, formatted ready for output. array
get_valid_statuses() Get all valid statuses for this order array
get_user_id() Get user ID. Used by orders, not other order types like refunds. int
get_user() Get user. Used by orders, not other order types like refunds. WP_User|false
set_parent_id() Set parent order ID. mixed
set_status() Set order status. array
set_version() Set order_version. mixed
set_currency() Set order_currency. mixed
set_prices_include_tax() Set prices_include_tax. mixed
set_date_created() Set date_created. mixed
set_date_modified() Set date_modified. mixed
set_discount_total() Set discount_total. mixed
set_discount_tax() Set discount_tax. mixed
set_shipping_total() Set shipping_total. mixed
set_shipping_tax() Set shipping_tax. mixed
set_cart_tax() Set cart tax. mixed
set_total_tax() Sets order tax (sum of cart and shipping tax). Used internally only. mixed
set_total() Set total. bool|void
remove_order_items() Remove all line items (products, coupons, shipping, taxes) from the order. mixed
type_to_group() Convert a type to a types group. string
get_items() Return an array of items/products within this order. \WC_Order_Item[]
get_values_for_total() Line items to calculate. Define in child class. array
get_coupons() Return an array of coupons within this order. \WC_Order_Item_Coupon[]
get_fees() Return an array of fees within this order. \WC_Order_item_Fee[]
get_taxes() Return an array of taxes within this order. \WC_Order_Item_Tax[]
get_shipping_methods() Return an array of shipping costs within this order. \WC_Order_Item_Shipping[]
get_shipping_method() Gets formatted shipping method title. string
get_coupon_codes() Get used coupon codes only. array
get_item_count() Gets the count of order items of a certain type. int|string
get_item() Get an order item object, based on its type. WC_Order_Item|false
get_items_key() Get key for where a certain item type is stored in _items. string
remove_item() Remove item from the order. false|void
add_item() Adds an order item to this order. The order item will not persist until save. false|void
hold_applied_coupons() Check and records coupon usage tentatively so that counts validation is correct. Display an error if coupon usage limit has been reached. mixed
hold_coupon() Hold coupon if a global usage limit is defined. string
hold_coupon_for_users() Hold coupon if usage limit per customer is defined. string
get_billing_and_current_user_aliases() Helper method to get all aliases for current user and provide billing email. array
apply_coupon() Apply a coupon to the order and recalculate totals. true|WP_Error
remove_coupon() Remove a coupon from the order and recalculate totals. void
recalculate_coupons() Apply all coupons in this order again to all line items. mixed
set_item_discount_amounts() After applying coupons via the WC_Discounts class, update line items. mixed
set_coupon_discount_amounts() After applying coupons via the WC_Discounts class, update or create coupon items. mixed
add_product() Add a product line item to the order. This is the only line item type with its own method because it saves looking up order amounts (costs are added up for you). int
add_payment_token() Add a payment token to an order bool|int
get_payment_tokens() Returns a list of all payment tokens associated with the current order array
calculate_shipping() Calculate shipping total. float
get_items_tax_classes() Get all tax classes for items in the order. array
get_tax_location() Get tax location for this order. array
calculate_taxes() Calculate taxes for all line items and shipping, and store the totals and tax rows. mixed
get_total_fees() Calculate fees for all line items. float
update_taxes() Update tax lines for the order based on the line item taxes themselves. mixed
get_cart_subtotal_for_order() Helper function. float
get_cart_total_for_order() Helper function. float
calculate_totals() Calculate totals by looking at the contents of the order. Stores the totals and returns the orders final total. float
get_item_subtotal() Get item subtotal - this is the cost before discount. float
get_line_subtotal() Get line subtotal - this is the cost before discount. float
get_item_total() Calculate item cost - useful for gateways. float
get_line_total() Calculate line total - useful for gateways. float
get_item_tax() Get item tax - useful for gateways. float
get_line_tax() Get line tax - useful for gateways. float
get_formatted_line_subtotal() Gets line subtotal - formatted for display. string
get_formatted_order_total() Gets order total - formatted for display. string
get_subtotal_to_display() Gets subtotal - subtotal is shown before discounts, but with localised taxes. string
get_shipping_to_display() Gets shipping (formatted). string
get_discount_to_display() Get the discount amount (formatted). string
add_order_item_totals_subtotal_row() Add total row for subtotal. mixed
add_order_item_totals_discount_row() Add total row for discounts. mixed
add_order_item_totals_shipping_row() Add total row for shipping. mixed
add_order_item_totals_fee_rows() Add total row for fees. mixed
add_order_item_totals_tax_rows() Add total row for taxes. mixed
add_order_item_totals_total_row() Add total row for grand total. mixed
get_order_item_totals() Get totals for display on pages and in emails. array
has_status() Checks the order status against a passed in status. bool
has_shipping_method() Check whether this order has a specific shipping method or not. bool
has_free_item() Returns true if the order contains a free product. bool
get_rounded_items_total() Return rounded total based on settings. Will be used by Cart and Orders. float|int
round_item_subtotal() Apply rounding to item subtotal before summing. float
round_at_subtotal() Should always round at subtotal? bool
round_line_tax() Apply rounding to an array of taxes before summing. Rounds to store DP setting, ignoring precision. float
add_coupon() Add coupon code to the order. int
add_tax() Add a tax row to the order. int
add_shipping() Add a shipping row to the order. int
add_fee() Add a fee to the order. int
update_product() Update a line item for the order. int
update_coupon() Update coupon for order. Note this does not update order totals. int
update_shipping() Update shipping method for order. int
update_fee() Update fee for order. int
update_tax() Update tax line on order. int
get_product_from_item() Get a product (either product or variation). WC_Product|bool
set_address() Set the customer address. mixed
legacy_set_total() Set an order total. bool
__isset() Magic __isset method for backwards compatibility. Handles legacy properties which could be accessed directly in the past. bool
__get() Magic __get method for backwards compatibility. mixed
has_meta() has_meta function for order items. This is different to the WC_Data version and should be removed in future versions. array
display_item_meta() Display meta data belonging to an item. mixed
display_item_downloads() Display download links for an order item. mixed
get_download_url() Get the Download URL. string
get_item_downloads() Get the downloadable files for an item in this order. array
get_total_shipping() Gets shipping total. Alias of WC_Order::get_shipping_total(). float
get_item_meta() Get order item meta. array|string
get_item_meta_array() Get all item meta data in array format in the order it was saved. Does not group meta by key like get_item_meta(). array
get_used_coupons() Get coupon codes only. array
expand_item_meta() Expand item meta into the $item array. array
init() Load the order object. Called from the constructor. mixed
get_order() Gets an order from the database. bool
populate() Populates an order from the loaded post data. mixed
cancel_order() Cancel the order and restore the cart (before payment). mixed
record_product_sales() Record sales. mixed
increase_coupon_usage_counts() Increase applied coupon counts. mixed
decrease_coupon_usage_counts() Decrease applied coupon counts. mixed
reduce_order_stock() Reduce stock levels for all line items in the order. mixed
send_stock_notifications() Send the stock notifications. mixed
email_order_items_table() Output items for display in html emails. string
get_order_currency() Get currency. mixed
__sleep() Only store the object ID to avoid serializing the data object instance. array
__wakeup() Re-run the constructor with the object ID. mixed
__clone() When the object is cloned, make sure meta is duplicated correctly. mixed
get_data_store() Get the data store. object
get_id() Returns the unique ID for this object. int
delete() Delete an object, set the ID to 0, and return result. bool
__toString() Change data to JSON format. string
get_data_keys() Returns array of expected data keys for this object. array
get_extra_data_keys() Returns all "extra" data keys for an object (for sub objects like product types). array
filter_null_meta() Filter null meta values from array. bool
get_meta_data() Get All Meta Data. array
is_internal_meta_key() Check if the key is an internal one. bool
get_meta() Get Meta Data by Key. mixed
meta_exists() See if meta data exists, since get_meta always returns a '' or array(). bool
set_meta_data() Set all meta data from array. mixed
add_meta_data() Add meta data. mixed
update_meta_data() Update meta data by key or ID, if provided. mixed
delete_meta_data() Delete meta data. mixed
delete_meta_data_by_mid() Delete meta data. mixed
maybe_read_meta_data() Read meta data if null. mixed
read_meta_data() Read Meta Data from the database. Ignore any internal properties. mixed
save_meta_data() Update Meta Data in the database. mixed
set_id() Set ID. mixed
set_defaults() Set all props to default values. mixed
set_object_read() Set object read property. mixed
get_object_read() Get object read property. bool
set_props() Set a collection of props in one go, collect any errors, and return the result. bool|WP_Error
set_prop() Sets a prop for a setter method. mixed
get_changes() Return data changes only. array
apply_changes() Merge changes with data and clear. mixed
get_hook_prefix() Prefix for action and filter hooks on data. string
get_prop() Gets a prop for a getter method. mixed
set_date_prop() Sets a date prop whilst handling formatting and datetime objects. mixed
error() When invalid data is found, throw an exception unless reading from the DB. mixed

Properties

$status_transition

Stores data about status changes so relevant hooks can be fired.

protected bool|array $status_transition = \false

$data

Order Data array. This is the core order data exposed in APIs since 3.0.0.

protected array $data = array( // Abstract order props. 'parent_id' => 0, 'status' => '', 'currency' => '', 'version' => '', 'prices_include_tax' => \false, 'date_created' => \null, 'date_modified' => \null, 'discount_total' => 0, 'discount_tax' => 0, 'shipping_total' => 0, 'shipping_tax' => 0, 'cart_tax' => 0, 'total' => 0, 'total_tax' => 0, // Order props. 'customer_id' => 0, 'order_key' => '', 'billing' => array('first_name' => '', 'last_name' => '', 'company' => '', 'address_1' => '', 'address_2' => '', 'city' => '', 'state' => '', 'postcode' => '', 'country' => '', 'email' => '', 'phone' => ''), 'shipping' => array('first_name' => '', 'last_name' => '', 'company' => '', 'address_1' => '', 'address_2' => '', 'city' => '', 'state' => '', 'postcode' => '', 'country' => ''), 'payment_method' => '', 'payment_method_title' => '', 'transaction_id' => '', 'customer_ip_address' => '', 'customer_user_agent' => '', 'created_via' => '', 'customer_note' => '', 'date_completed' => \null, 'date_paid' => \null, 'cart_hash' => '', )
Notes: cart_tax = cart_tax is the new name for the legacy 'order_tax' which is the tax for items only, not shipping.

$data

Core data for this object. Name value pairs (name + default value).

protected array $data = array()

$items

Order items will be stored here, sometimes before they persist in the DB.

protected array $items = array()

$items_to_delete

Order items that need deleting are stored here.

protected array $items_to_delete = array()

$cache_group

Stores meta in cache for future reads.

protected string $cache_group = ''
A group must be set to to enable caching.

$data_store_name

Which data store to load.

protected string $data_store_name = 'order'

$object_type

This is the name of this object type.

protected string $object_type = 'data'

$changes

Core data changes for this object.

protected array $changes = array()

$object_read

This is false until the object is read from the DB.

protected bool $object_read = \false

$extra_data

Extra data for this object. Name value pairs (name + default value).

protected array $extra_data = array()
Used as a standard way for sub classes (like product types) to add additional information to an inherited class.

$default_data

Set to _data on construct so we can track and reset data if needed.

protected array $default_data = array()

$data_store

Contains a reference to the data store for this class.

protected object $data_store

$meta_data

Stores additional meta data.

protected array $meta_data = \null

Methods

payment_complete()

When a payment is complete this function is called.

public payment_complete( [ $transaction_id : string = '' ] ) : bool

Most of the time this should mark an order as 'processing' so that admin can process/post the items. If the cart contains only downloadable items then the order is 'completed' since the admin needs to take no action. Stock levels are reduced at this point. Sales are also recorded for products. Finally, record the date of payment.

Parameters
$transaction_id : string = ''

Optional transaction id to store in post meta.

Return values
bool

success

get_formatted_order_total()

Gets order total - formatted for display.

public get_formatted_order_total( [ $tax_display : string = '' ] [, $display_refunded : bool = true ] ) : string
Parameters
$tax_display : string = ''

Type of tax display.

$display_refunded : bool = true

If should include refunded value.

Return values
string

save()

Save data to the database.

public save( ) : int
Tags
since
Return values
int

order ID

handle_exception()

Log an error about this order is exception is encountered.

protected handle_exception( $e : Exception [, $message : string = 'Error' ] ) : mixed
Parameters
$e : Exception

Exception object.

$message : string = 'Error'

Message regarding exception thrown.

Tags
since
Return values
mixed

set_status()

Set order status.

public set_status( $new_status : string [, $note : string = '' ] [, $manual_update : bool = false ] ) : array
Parameters
$new_status : string

Status to change the order to. No internal wc- prefix is required.

$note : string = ''

Optional note to add.

$manual_update : bool = false

Is this a manual order status change?.

Tags
since
Return values
array

maybe_set_date_paid()

Maybe set date paid.

public maybe_set_date_paid( ) : mixed

Sets the date paid variable when transitioning to the payment complete order status. This is either processing or completed. This is not filtered to avoid infinite loops e.g. if loading an order via the filter.

Date paid is set once in this manner - only when it is not already set. This ensures the data exists even if a gateway does not use the payment_complete method.

Tags
since
Return values
mixed

maybe_set_date_completed()

Maybe set date completed.

protected maybe_set_date_completed( ) : mixed

Sets the date completed variable when transitioning to completed status.

Tags
since
Return values
mixed

update_status()

Updates status of order immediately.

public update_status( $new_status : string [, $note : string = '' ] [, $manual : bool = false ] ) : bool
Parameters
$new_status : string

Status to change the order to. No internal wc- prefix is required.

$note : string = ''

Optional note to add.

$manual : bool = false

Is this a manual order status change?.

Tags
uses
Return values
bool

status_transition()

Handle the status transition.

protected status_transition( ) : mixed
Return values
mixed

get_base_data()

Get basic order data in array format.

public get_base_data( ) : array
Return values
array

get_data()

Get all class data in array format.

public get_data( ) : array
Tags
since
Return values
array

get_changes()

Expands the shipping and billing information in the changes array.

public get_changes( ) : mixed
Return values
mixed

get_order_number()

Gets the order number for display (by default, order ID).

public get_order_number( ) : string
Return values
string

get_order_key()

Get order key.

public get_order_key( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Tags
since
Return values
string

get_customer_id()

Get customer_id.

public get_customer_id( [ $context : string = 'view' ] ) : int
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
int

get_user_id()

Alias for get_customer_id().

public get_user_id( [ $context : string = 'view' ] ) : int
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
int

get_user()

Get the user associated with the order. False for guests.

public get_user( ) : WP_User|false
Return values
WP_User|false

get_address_prop()

Gets a prop for a getter method.

protected get_address_prop( $prop : string [, $address : string = 'billing' ] [, $context : string = 'view' ] ) : mixed
Parameters
$prop : string

Name of prop to get.

$address : string = 'billing'

billing or shipping.

$context : string = 'view'

What the value is for. Valid values are view and edit.

Tags
since
Return values
mixed

get_billing_first_name()

Get billing first name.

public get_billing_first_name( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_billing_last_name()

Get billing last name.

public get_billing_last_name( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_billing_company()

Get billing company.

public get_billing_company( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_billing_address_1()

Get billing address line 1.

public get_billing_address_1( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_billing_address_2()

Get billing address line 2.

public get_billing_address_2( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_billing_city()

Get billing city.

public get_billing_city( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_billing_state()

Get billing state.

public get_billing_state( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_billing_postcode()

Get billing postcode.

public get_billing_postcode( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_billing_country()

Get billing country.

public get_billing_country( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_billing_email()

Get billing email.

public get_billing_email( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_billing_phone()

Get billing phone.

public get_billing_phone( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_shipping_first_name()

Get shipping first name.

public get_shipping_first_name( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_shipping_last_name()

Get shipping_last_name.

public get_shipping_last_name( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_shipping_company()

Get shipping company.

public get_shipping_company( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_shipping_address_1()

Get shipping address line 1.

public get_shipping_address_1( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_shipping_address_2()

Get shipping address line 2.

public get_shipping_address_2( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_shipping_city()

Get shipping city.

public get_shipping_city( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_shipping_state()

Get shipping state.

public get_shipping_state( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_shipping_postcode()

Get shipping postcode.

public get_shipping_postcode( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_shipping_country()

Get shipping country.

public get_shipping_country( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_payment_method()

Get the payment method.

public get_payment_method( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_payment_method_title()

Get payment method title.

public get_payment_method_title( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_transaction_id()

Get transaction d.

public get_transaction_id( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_customer_ip_address()

Get customer ip address.

public get_customer_ip_address( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_customer_user_agent()

Get customer user agent.

public get_customer_user_agent( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_created_via()

Get created via.

public get_created_via( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_customer_note()

Get customer note.

public get_customer_note( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_date_completed()

Get date completed.

public get_date_completed( [ $context : string = 'view' ] ) : WC_DateTime|null
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
WC_DateTime|null

object if the date is set or null if there is no date.

get_date_paid()

Get date paid.

public get_date_paid( [ $context : string = 'view' ] ) : WC_DateTime|null
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
WC_DateTime|null

object if the date is set or null if there is no date.

get_cart_hash()

Get cart hash.

public get_cart_hash( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are view and edit.

Return values
string

get_address()

Returns the requested address in raw, non-formatted way.

public get_address( [ $type : string = 'billing' ] ) : array

Note: Merges raw data with get_prop data so changes are returned too.

Parameters
$type : string = 'billing'

Billing or shipping. Anything else besides 'billing' will return shipping address.

Tags
since
Return values
array

The stored address after filter.

get_shipping_address_map_url()

Get a formatted shipping address for the order.

public get_shipping_address_map_url( ) : string
Return values
string

get_formatted_billing_full_name()

Get a formatted billing full name.

public get_formatted_billing_full_name( ) : string
Return values
string

get_formatted_shipping_full_name()

Get a formatted shipping full name.

public get_formatted_shipping_full_name( ) : string
Return values
string

get_formatted_billing_address()

Get a formatted billing address for the order.

public get_formatted_billing_address( [ $empty_content : string = '' ] ) : string
Parameters
$empty_content : string = ''

Content to show if no address is present. @since 3.3.0.

Return values
string

get_formatted_shipping_address()

Get a formatted shipping address for the order.

public get_formatted_shipping_address( [ $empty_content : string = '' ] ) : string
Parameters
$empty_content : string = ''

Content to show if no address is present. @since 3.3.0.

Return values
string

has_billing_address()

Returns true if the order has a billing address.

public has_billing_address( ) : bool
Tags
since
Return values
bool

has_shipping_address()

Returns true if the order has a shipping address.

public has_shipping_address( ) : bool
Tags
since
Return values
bool

set_address_prop()

Sets a prop for a setter method.

protected set_address_prop( $prop : string [, $address : string = 'billing' ] , $value : mixed ) : mixed
Parameters
$prop : string

Name of prop to set.

$address : string = 'billing'

Name of address to set. billing or shipping.

$value : mixed

Value of the prop.

Tags
since
Return values
mixed

set_order_key()

Set order key.

public set_order_key( $value : string ) : mixed
Parameters
$value : string

Max length 22 chars.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_customer_id()

Set customer id.

public set_customer_id( $value : int ) : mixed
Parameters
$value : int

Customer ID.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_billing_first_name()

Set billing first name.

public set_billing_first_name( $value : string ) : mixed
Parameters
$value : string

Billing first name.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_billing_last_name()

Set billing last name.

public set_billing_last_name( $value : string ) : mixed
Parameters
$value : string

Billing last name.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_billing_company()

Set billing company.

public set_billing_company( $value : string ) : mixed
Parameters
$value : string

Billing company.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_billing_address_1()

Set billing address line 1.

public set_billing_address_1( $value : string ) : mixed
Parameters
$value : string

Billing address line 1.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_billing_address_2()

Set billing address line 2.

public set_billing_address_2( $value : string ) : mixed
Parameters
$value : string

Billing address line 2.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_billing_city()

Set billing city.

public set_billing_city( $value : string ) : mixed
Parameters
$value : string

Billing city.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_billing_state()

Set billing state.

public set_billing_state( $value : string ) : mixed
Parameters
$value : string

Billing state.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_billing_postcode()

Set billing postcode.

public set_billing_postcode( $value : string ) : mixed
Parameters
$value : string

Billing postcode.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_billing_country()

Set billing country.

public set_billing_country( $value : string ) : mixed
Parameters
$value : string

Billing country.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

maybe_set_user_billing_email()

Maybe set empty billing email to that of the user who owns the order.

protected maybe_set_user_billing_email( ) : mixed
Return values
mixed

set_billing_email()

Set billing email.

public set_billing_email( $value : string ) : mixed
Parameters
$value : string

Billing email.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_billing_phone()

Set billing phone.

public set_billing_phone( $value : string ) : mixed
Parameters
$value : string

Billing phone.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_shipping_first_name()

Set shipping first name.

public set_shipping_first_name( $value : string ) : mixed
Parameters
$value : string

Shipping first name.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_shipping_last_name()

Set shipping last name.

public set_shipping_last_name( $value : string ) : mixed
Parameters
$value : string

Shipping last name.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_shipping_company()

Set shipping company.

public set_shipping_company( $value : string ) : mixed
Parameters
$value : string

Shipping company.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_shipping_address_1()

Set shipping address line 1.

public set_shipping_address_1( $value : string ) : mixed
Parameters
$value : string

Shipping address line 1.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_shipping_address_2()

Set shipping address line 2.

public set_shipping_address_2( $value : string ) : mixed
Parameters
$value : string

Shipping address line 2.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_shipping_city()

Set shipping city.

public set_shipping_city( $value : string ) : mixed
Parameters
$value : string

Shipping city.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_shipping_state()

Set shipping state.

public set_shipping_state( $value : string ) : mixed
Parameters
$value : string

Shipping state.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_shipping_postcode()

Set shipping postcode.

public set_shipping_postcode( $value : string ) : mixed
Parameters
$value : string

Shipping postcode.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_shipping_country()

Set shipping country.

public set_shipping_country( $value : string ) : mixed
Parameters
$value : string

Shipping country.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_payment_method()

Set the payment method.

public set_payment_method( [ $payment_method : string = '' ] ) : mixed
Parameters
$payment_method : string = ''

Supports WC_Payment_Gateway for bw compatibility with < 3.0.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_payment_method_title()

Set payment method title.

public set_payment_method_title( $value : string ) : mixed
Parameters
$value : string

Payment method title.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_transaction_id()

Set transaction id.

public set_transaction_id( $value : string ) : mixed
Parameters
$value : string

Transaction id.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_customer_ip_address()

Set customer ip address.

public set_customer_ip_address( $value : string ) : mixed
Parameters
$value : string

Customer ip address.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_customer_user_agent()

Set customer user agent.

public set_customer_user_agent( $value : string ) : mixed
Parameters
$value : string

Customer user agent.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_created_via()

Set created via.

public set_created_via( $value : string ) : mixed
Parameters
$value : string

Created via.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_customer_note()

Set customer note.

public set_customer_note( $value : string ) : mixed
Parameters
$value : string

Customer note.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_date_completed()

Set date completed.

public set_date_completed( [ $date : string|int|null = null ] ) : mixed
Parameters
$date : string|int|null = null

UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if their is no date.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_date_paid()

Set date paid.

public set_date_paid( [ $date : string|int|null = null ] ) : mixed
Parameters
$date : string|int|null = null

UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if their is no date.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

set_cart_hash()

Set cart hash.

public set_cart_hash( $value : string ) : mixed
Parameters
$value : string

Cart hash.

Tags
throws

Throws exception when invalid data is found.

Return values
mixed

key_is_valid()

Check if an order key is valid.

public key_is_valid( $key : string ) : bool
Parameters
$key : string

Order key.

Return values
bool

has_cart_hash()

See if order matches cart_hash.

public has_cart_hash( [ $cart_hash : string = '' ] ) : bool
Parameters
$cart_hash : string = ''

Cart hash.

Return values
bool

is_editable()

Checks if an order can be edited, specifically for use on the Edit Order screen.

public is_editable( ) : bool
Return values
bool

is_paid()

Returns if an order has been paid for based on the order status.

public is_paid( ) : bool
Tags
since
Return values
bool

is_download_permitted()

Checks if product download is permitted.

public is_download_permitted( ) : bool
Return values
bool

needs_shipping_address()

Checks if an order needs display the shipping address, based on shipping method.

public needs_shipping_address( ) : bool
Return values
bool

has_downloadable_item()

Returns true if the order contains a downloadable product.

public has_downloadable_item( ) : bool
Return values
bool

get_downloadable_items()

Get downloads from all line items for this order.

public get_downloadable_items( ) : array
Tags
since
Return values
array

needs_payment()

Checks if an order needs payment, based on status and order total.

public needs_payment( ) : bool
Return values
bool

needs_processing()

See if the order needs processing before it can be completed.

public needs_processing( ) : bool

Orders which only contain virtual, downloadable items do not need admin intervention.

Uses a transient so these calls are not repeated multiple times, and because once the order is processed this code/transient does not need to persist.

Tags
since
Return values
bool

get_checkout_payment_url()

Generates a URL so that a customer can pay for their (unpaid - pending) order. Pass 'true' for the checkout version which doesn't offer gateway choices.

public get_checkout_payment_url( [ $on_checkout : bool = false ] ) : string
Parameters
$on_checkout : bool = false

If on checkout.

Return values
string

get_checkout_order_received_url()

Generates a URL for the thanks page (order received).

public get_checkout_order_received_url( ) : string
Return values
string

get_cancel_order_url()

Generates a URL so that a customer can cancel their (unpaid - pending) order.

public get_cancel_order_url( [ $redirect : string = '' ] ) : string
Parameters
$redirect : string = ''

Redirect URL.

Return values
string

get_cancel_order_url_raw()

Generates a raw (unescaped) cancel-order URL for use by payment gateways.

public get_cancel_order_url_raw( [ $redirect : string = '' ] ) : string
Parameters
$redirect : string = ''

Redirect URL.

Return values
string

The unescaped cancel-order URL.

get_cancel_endpoint()

Helper method to return the cancel endpoint.

public get_cancel_endpoint( ) : string
Return values
string

the cancel endpoint; either the cart page or the home page.

get_view_order_url()

Generates a URL to view an order from the my account page.

public get_view_order_url( ) : string
Return values
string

get_edit_order_url()

Get's the URL to edit the order in the backend.

public get_edit_order_url( ) : string
Tags
since
Return values
string

add_order_note()

Adds a note (comment) to the order. Order must exist.

public add_order_note( $note : string , $is_customer_note : int [, $added_by_user : bool = false ] ) : int
Parameters
$note : string

Note to add.

$is_customer_note : int

Is this a note for the customer?.

$added_by_user : bool = false

Was the note added by a user?.

Return values
int

Comment ID.

add_status_transition_note()

Add an order note for status transition

private add_status_transition_note( $note : string , $transition : bool ) : int
Parameters
$note : string

Note to be added giving status transition from and to details.

$transition : bool

Details of the status transition.

Tags
since
uses
Return values
int

Comment ID.

get_customer_order_notes()

List order notes (public) for the customer.

public get_customer_order_notes( ) : array
Return values
array

get_refunds()

Get order refunds.

public get_refunds( ) : array
Tags
since
Return values
array

of WC_Order_Refund objects

get_total_refunded()

Get amount already refunded.

public get_total_refunded( ) : string
Tags
since
Return values
string

get_total_tax_refunded()

Get the total tax refunded.

public get_total_tax_refunded( ) : float
Tags
since
Return values
float

get_total_shipping_refunded()

Get the total shipping refunded.

public get_total_shipping_refunded( ) : float
Tags
since
Return values
float

get_item_count_refunded()

Gets the count of order items of a certain type that have been refunded.

public get_item_count_refunded( [ $item_type : string = '' ] ) : string
Parameters
$item_type : string = ''

Item type.

Tags
since
Return values
string

get_total_qty_refunded()

Get the total number of items refunded.

public get_total_qty_refunded( [ $item_type : string = 'line_item' ] ) : int
Parameters
$item_type : string = 'line_item'

Type of the item we're checking, if not a line_item.

Tags
since
Return values
int

get_qty_refunded_for_item()

Get the refunded amount for a line item.

public get_qty_refunded_for_item( $item_id : int [, $item_type : string = 'line_item' ] ) : int
Parameters
$item_id : int

ID of the item we're checking.

$item_type : string = 'line_item'

Type of the item we're checking, if not a line_item.

Return values
int

get_total_refunded_for_item()

Get the refunded amount for a line item.

public get_total_refunded_for_item( $item_id : int [, $item_type : string = 'line_item' ] ) : int
Parameters
$item_id : int

ID of the item we're checking.

$item_type : string = 'line_item'

Type of the item we're checking, if not a line_item.

Return values
int

get_tax_refunded_for_item()

Get the refunded tax amount for a line item.

public get_tax_refunded_for_item( $item_id : int , $tax_id : int [, $item_type : string = 'line_item' ] ) : float
Parameters
$item_id : int

ID of the item we're checking.

$tax_id : int

ID of the tax we're checking.

$item_type : string = 'line_item'

Type of the item we're checking, if not a line_item.

Return values
float

get_total_tax_refunded_by_rate_id()

Get total tax refunded by rate ID.

public get_total_tax_refunded_by_rate_id( $rate_id : int ) : float
Parameters
$rate_id : int

Rate ID.

Return values
float

get_remaining_refund_amount()

How much money is left to refund?

public get_remaining_refund_amount( ) : string
Return values
string

get_remaining_refund_items()

How many items are left to refund?

public get_remaining_refund_items( ) : int
Return values
int

add_order_item_totals_payment_method_row()

Add total row for the payment method.

protected add_order_item_totals_payment_method_row( &$total_rows : array , $tax_display : string ) : mixed
Parameters
$total_rows : array

Total rows.

$tax_display : string

Tax to display.

Return values
mixed

add_order_item_totals_refund_rows()

Add total row for refunds.

protected add_order_item_totals_refund_rows( &$total_rows : array , $tax_display : string ) : mixed
Parameters
$total_rows : array

Total rows.

$tax_display : string

Tax to display.

Return values
mixed

get_order_item_totals()

Get totals for display on pages and in emails.

public get_order_item_totals( [ $tax_display : string = '' ] ) : array
Parameters
$tax_display : string = ''

Tax to display.

Return values
array

is_created_via()

Check if order has been created via admin, checkout, or in another way.

public is_created_via( $modus : string ) : bool
Parameters
$modus : string

Way of creating the order to test for.

Tags
since
Return values
bool

__construct()

Default constructor.

public __construct( $read : int|object|array ) : mixed
Parameters
$read : int|object|array

ID to load from the DB (optional) or already queried data.

Return values
mixed

get_type()

Get internal type.

public get_type( ) : string
Return values
string

get_data()

Returns all data for this object.

public get_data( ) : array
Tags
since
Return values
array

save()

Save should create or update based on object existence.

public save( ) : int
Tags
since
Return values
int

handle_exception()

Log an error about this order is exception is encountered.

protected handle_exception( $e : Exception [, $message : string = 'Error' ] ) : mixed
Parameters
$e : Exception

Exception object.

$message : string = 'Error'

Message regarding exception thrown.

Tags
since
Return values
mixed

save_items()

Save all order items which are part of this order.

protected save_items( ) : mixed
Return values
mixed

get_parent_id()

Get parent order ID.

public get_parent_id( [ $context : string = 'view' ] ) : int
Parameters
$context : string = 'view'

View or edit context.

Tags
since
Return values
int

get_currency()

Gets order currency.

public get_currency( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

View or edit context.

Return values
string

get_version()

Get order_version.

public get_version( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

View or edit context.

Return values
string

get_prices_include_tax()

Get prices_include_tax.

public get_prices_include_tax( [ $context : string = 'view' ] ) : bool
Parameters
$context : string = 'view'

View or edit context.

Return values
bool

get_date_created()

Get date_created.

public get_date_created( [ $context : string = 'view' ] ) : WC_DateTime|null
Parameters
$context : string = 'view'

View or edit context.

Return values
WC_DateTime|null

object if the date is set or null if there is no date.

get_date_modified()

Get date_modified.

public get_date_modified( [ $context : string = 'view' ] ) : WC_DateTime|null
Parameters
$context : string = 'view'

View or edit context.

Return values
WC_DateTime|null

object if the date is set or null if there is no date.

get_status()

Return the order statuses without wc- internal prefix.

public get_status( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

View or edit context.

Return values
string

get_discount_total()

Get discount_total.

public get_discount_total( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

View or edit context.

Return values
string

get_discount_tax()

Get discount_tax.

public get_discount_tax( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

View or edit context.

Return values
string

get_shipping_total()

Get shipping_total.

public get_shipping_total( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

View or edit context.

Return values
string

get_shipping_tax()

Get shipping_tax.

public get_shipping_tax( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

View or edit context.

Return values
string

get_cart_tax()

Gets cart tax amount.

public get_cart_tax( [ $context : string = 'view' ] ) : float
Parameters
$context : string = 'view'

View or edit context.

Return values
float

get_total()

Gets order grand total. incl. taxes. Used in gateways.

public get_total( [ $context : string = 'view' ] ) : float
Parameters
$context : string = 'view'

View or edit context.

Return values
float

get_total_tax()

Get total tax amount. Alias for get_order_tax().

public get_total_tax( [ $context : string = 'view' ] ) : float
Parameters
$context : string = 'view'

View or edit context.

Return values
float

get_total_discount()

Gets the total discount amount.

public get_total_discount( [ $ex_tax : bool = true ] ) : float
Parameters
$ex_tax : bool = true

Show discount excl any tax.

Return values
float

get_subtotal()

Gets order subtotal.

public get_subtotal( ) : float
Return values
float

get_tax_totals()

Get taxes, merged by code, formatted ready for output.

public get_tax_totals( ) : array
Return values
array

get_valid_statuses()

Get all valid statuses for this order

protected get_valid_statuses( ) : array
Tags
since
Return values
array

Internal status keys e.g. 'wc-processing'

get_user_id()

Get user ID. Used by orders, not other order types like refunds.

public get_user_id( [ $context : string = 'view' ] ) : int
Parameters
$context : string = 'view'

View or edit context.

Return values
int

get_user()

Get user. Used by orders, not other order types like refunds.

public get_user( ) : WP_User|false
Return values
WP_User|false

set_parent_id()

Set parent order ID.

public set_parent_id( $value : int ) : mixed
Parameters
$value : int

Value to set.

Tags
since
throws

Exception thrown if parent ID does not exist or is invalid.

Return values
mixed

set_status()

Set order status.

public set_status( $new_status : string ) : array
Parameters
$new_status : string

Status to change the order to. No internal wc- prefix is required.

Tags
since
Return values
array

details of change

set_version()

Set order_version.

public set_version( $value : string ) : mixed
Parameters
$value : string

Value to set.

Tags
throws

Exception may be thrown if value is invalid.

Return values
mixed

set_currency()

Set order_currency.

public set_currency( $value : string ) : mixed
Parameters
$value : string

Value to set.

Tags
throws

Exception may be thrown if value is invalid.

Return values
mixed

set_prices_include_tax()

Set prices_include_tax.

public set_prices_include_tax( $value : bool ) : mixed
Parameters
$value : bool

Value to set.

Tags
throws

Exception may be thrown if value is invalid.

Return values
mixed

set_date_created()

Set date_created.

public set_date_created( [ $date : string|int|null = null ] ) : mixed
Parameters
$date : string|int|null = null

UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if there is no date.

Tags
throws

Exception may be thrown if value is invalid.

Return values
mixed

set_date_modified()

Set date_modified.

public set_date_modified( [ $date : string|int|null = null ] ) : mixed
Parameters
$date : string|int|null = null

UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if there is no date.

Tags
throws

Exception may be thrown if value is invalid.

Return values
mixed

set_discount_total()

Set discount_total.

public set_discount_total( $value : string ) : mixed
Parameters
$value : string

Value to set.

Tags
throws

Exception may be thrown if value is invalid.

Return values
mixed

set_discount_tax()

Set discount_tax.

public set_discount_tax( $value : string ) : mixed
Parameters
$value : string

Value to set.

Tags
throws

Exception may be thrown if value is invalid.

Return values
mixed

set_shipping_total()

Set shipping_total.

public set_shipping_total( $value : string ) : mixed
Parameters
$value : string

Value to set.

Tags
throws

Exception may be thrown if value is invalid.

Return values
mixed

set_shipping_tax()

Set shipping_tax.

public set_shipping_tax( $value : string ) : mixed
Parameters
$value : string

Value to set.

Tags
throws

Exception may be thrown if value is invalid.

Return values
mixed

set_cart_tax()

Set cart tax.

public set_cart_tax( $value : string ) : mixed
Parameters
$value : string

Value to set.

Tags
throws

Exception may be thrown if value is invalid.

Return values
mixed

set_total_tax()

Sets order tax (sum of cart and shipping tax). Used internally only.

protected set_total_tax( $value : string ) : mixed
Parameters
$value : string

Value to set.

Tags
throws

Exception may be thrown if value is invalid.

Return values
mixed

set_total()

Set total.

public set_total( $value : string [, $deprecated : string = '' ] ) : bool|void
Parameters
$value : string

Value to set.

$deprecated : string = ''

Function used to set different totals based on this.

Tags
throws

Exception may be thrown if value is invalid.

Return values
bool|void

remove_order_items()

Remove all line items (products, coupons, shipping, taxes) from the order.

public remove_order_items( [ $type : string = null ] ) : mixed
Parameters
$type : string = null

Order item type. Default null.

Return values
mixed

type_to_group()

Convert a type to a types group.

protected type_to_group( $type : string ) : string
Parameters
$type : string

type to lookup.

Return values
string

get_items()

Return an array of items/products within this order.

public get_items( [ $types : string|array = 'line_item' ] ) : \WC_Order_Item[]
Parameters
$types : string|array = 'line_item'

Types of line items to get (array or string).

Return values
\WC_Order_Item[]

get_values_for_total()

Line items to calculate. Define in child class.

protected abstract get_values_for_total( $field : string ) : array
Parameters
$field : string

Field name to calculate upon.

Tags
since
Return values
array

having total|subtotal property.

get_coupons()

Return an array of coupons within this order.

public get_coupons( ) : \WC_Order_Item_Coupon[]
Tags
since
Return values
\WC_Order_Item_Coupon[]

get_fees()

Return an array of fees within this order.

public get_fees( ) : \WC_Order_item_Fee[]
Return values
\WC_Order_item_Fee[]

get_taxes()

Return an array of taxes within this order.

public get_taxes( ) : \WC_Order_Item_Tax[]
Return values
\WC_Order_Item_Tax[]

get_shipping_methods()

Return an array of shipping costs within this order.

public get_shipping_methods( ) : \WC_Order_Item_Shipping[]
Return values
\WC_Order_Item_Shipping[]

get_shipping_method()

Gets formatted shipping method title.

public get_shipping_method( ) : string
Return values
string

get_coupon_codes()

Get used coupon codes only.

public get_coupon_codes( ) : array
Tags
since
Return values
array

get_item_count()

Gets the count of order items of a certain type.

public get_item_count( [ $item_type : string = '' ] ) : int|string
Parameters
$item_type : string = ''

Item type to lookup.

Return values
int|string

get_item()

Get an order item object, based on its type.

public get_item( $item_id : int [, $load_from_db : bool = true ] ) : WC_Order_Item|false
Parameters
$item_id : int

ID of item to get.

$load_from_db : bool = true

Prior to 3.2 this item was loaded direct from WC_Order_Factory, not this object. This param is here for backwards compatility with that. If false, uses the local items variable instead.

Tags
since
Return values
WC_Order_Item|false

get_items_key()

Get key for where a certain item type is stored in _items.

protected get_items_key( $item : string ) : string
Parameters
$item : string

object Order item (product, shipping, fee, coupon, tax).

Tags
since
Return values
string

remove_item()

Remove item from the order.

public remove_item( $item_id : int ) : false|void
Parameters
$item_id : int

Item ID to delete.

Return values
false|void

add_item()

Adds an order item to this order. The order item will not persist until save.

public add_item( $item : WC_Order_Item ) : false|void
Parameters
$item : WC_Order_Item

Order item object (product, shipping, fee, coupon, tax).

Tags
since
Return values
false|void

hold_applied_coupons()

Check and records coupon usage tentatively so that counts validation is correct. Display an error if coupon usage limit has been reached.

public hold_applied_coupons( $billing_email : string ) : mixed

If you are using this method, make sure to release_held_coupons in case an Exception is thrown.

Parameters
$billing_email : string

Billing email of order.

Tags
throws

When not able to apply coupon.

Return values
mixed

hold_coupon()

Hold coupon if a global usage limit is defined.

private hold_coupon( $coupon : WC_Coupon ) : string
Parameters
$coupon : WC_Coupon

Coupon object.

Tags
throws

When can't be held.

Return values
string

Meta key which indicates held coupon.

hold_coupon_for_users()

Hold coupon if usage limit per customer is defined.

private hold_coupon_for_users( $coupon : WC_Coupon , $user_ids_and_emails : array , $user_alias : string ) : string
Parameters
$coupon : WC_Coupon

Coupon object.

$user_ids_and_emails : array

Array of user Id and emails to check for usage limit.

$user_alias : string

User ID or email to use to record current usage.

Tags
throws

When coupon can't be held.

Return values
string

Meta key which indicates held coupon.

get_billing_and_current_user_aliases()

Helper method to get all aliases for current user and provide billing email.

private get_billing_and_current_user_aliases( $billing_email : string ) : array
Parameters
$billing_email : string

Billing email provided in form.

Tags
throws

When validation fails.

Return values
array

Array of all aliases.

apply_coupon()

Apply a coupon to the order and recalculate totals.

public apply_coupon( $raw_coupon : string|WC_Coupon ) : true|WP_Error
Parameters
$raw_coupon : string|WC_Coupon

Coupon code or object.

Tags
since
Return values
true|WP_Error

True if applied, error if not.

remove_coupon()

Remove a coupon from the order and recalculate totals.

public remove_coupon( $code : string ) : void

Coupons affect line item totals, but there is no relationship between coupon and line total, so to remove a coupon we need to work from the line subtotal (price before discount) and re-apply all coupons in this order.

Manual discounts are not affected; those are separate and do not affect stored line totals.

Parameters
$code : string

Coupon code.

Tags
since

recalculate_coupons()

Apply all coupons in this order again to all line items.

public recalculate_coupons( ) : mixed

This method is public since WooCommerce 3.8.0.

Tags
since
Return values
mixed

set_item_discount_amounts()

After applying coupons via the WC_Discounts class, update line items.

protected set_item_discount_amounts( $discounts : WC_Discounts ) : mixed
Parameters
$discounts : WC_Discounts

Discounts class.

Tags
since
Return values
mixed

set_coupon_discount_amounts()

After applying coupons via the WC_Discounts class, update or create coupon items.

protected set_coupon_discount_amounts( $discounts : WC_Discounts ) : mixed
Parameters
$discounts : WC_Discounts

Discounts class.

Tags
since
Return values
mixed

add_product()

Add a product line item to the order. This is the only line item type with its own method because it saves looking up order amounts (costs are added up for you).

public add_product( $product : WC_Product [, $qty : int = 1 ] [, $args : array = array() ] ) : int
Parameters
$product : WC_Product

Product object.

$qty : int = 1

Quantity to add.

$args : array = array()

Args for the added product.

Tags
throws

Exception thrown if the item cannot be added to the cart.

Return values
int

add_payment_token()

Add a payment token to an order

public add_payment_token( $token : WC_Payment_Token ) : bool|int
Parameters
$token : WC_Payment_Token

Payment token object.

Tags
since
Return values
bool|int

The new token ID or false if it failed.

get_payment_tokens()

Returns a list of all payment tokens associated with the current order

public get_payment_tokens( ) : array
Tags
since
Return values
array

An array of payment token objects

calculate_shipping()

Calculate shipping total.

public calculate_shipping( ) : float
Tags
since
Return values
float

get_items_tax_classes()

Get all tax classes for items in the order.

public get_items_tax_classes( ) : array
Tags
since
Return values
array

get_tax_location()

Get tax location for this order.

protected get_tax_location( [ $args : array = array() ] ) : array
Parameters
$args : array = array()

array Override the location.

Tags
since
Return values
array

calculate_taxes()

Calculate taxes for all line items and shipping, and store the totals and tax rows.

public calculate_taxes( [ $args : array = array() ] ) : mixed

If by default the taxes are based on the shipping address and the current order doesn't have any, it would use the billing address rather than using the Shopping base location.

Will use the base country unless customer addresses are set.

Parameters
$args : array = array()

Added in 3.0.0 to pass things like location.

Return values
mixed

get_total_fees()

Calculate fees for all line items.

public get_total_fees( ) : float
Return values
float

Fee total.

update_taxes()

Update tax lines for the order based on the line item taxes themselves.

public update_taxes( ) : mixed
Return values
mixed

get_cart_subtotal_for_order()

Helper function.

protected get_cart_subtotal_for_order( ) : float

If you add all items in this order in cart again, this would be the cart subtotal (assuming all other settings are same).

Return values
float

Cart subtotal.

get_cart_total_for_order()

Helper function.

protected get_cart_total_for_order( ) : float

If you add all items in this order in cart again, this would be the cart total (assuming all other settings are same).

Return values
float

Cart total.

calculate_totals()

Calculate totals by looking at the contents of the order. Stores the totals and returns the orders final total.

public calculate_totals( [ $and_taxes : bool = true ] ) : float
Parameters
$and_taxes : bool = true

Calc taxes if true.

Tags
since
Return values
float

calculated grand total.

get_item_subtotal()

Get item subtotal - this is the cost before discount.

public get_item_subtotal( $item : object [, $inc_tax : bool = false ] [, $round : bool = true ] ) : float
Parameters
$item : object

Item to get total from.

$inc_tax : bool = false

(default: false).

$round : bool = true

(default: true).

Return values
float

get_line_subtotal()

Get line subtotal - this is the cost before discount.

public get_line_subtotal( $item : object [, $inc_tax : bool = false ] [, $round : bool = true ] ) : float
Parameters
$item : object

Item to get total from.

$inc_tax : bool = false

(default: false).

$round : bool = true

(default: true).

Return values
float

get_item_total()

Calculate item cost - useful for gateways.

public get_item_total( $item : object [, $inc_tax : bool = false ] [, $round : bool = true ] ) : float
Parameters
$item : object

Item to get total from.

$inc_tax : bool = false

(default: false).

$round : bool = true

(default: true).

Return values
float

get_line_total()

Calculate line total - useful for gateways.

public get_line_total( $item : object [, $inc_tax : bool = false ] [, $round : bool = true ] ) : float
Parameters
$item : object

Item to get total from.

$inc_tax : bool = false

(default: false).

$round : bool = true

(default: true).

Return values
float

get_item_tax()

Get item tax - useful for gateways.

public get_item_tax( $item : mixed [, $round : bool = true ] ) : float
Parameters
$item : mixed

Item to get total from.

$round : bool = true

(default: true).

Return values
float

get_line_tax()

Get line tax - useful for gateways.

public get_line_tax( $item : mixed ) : float
Parameters
$item : mixed

Item to get total from.

Return values
float

get_formatted_line_subtotal()

Gets line subtotal - formatted for display.

public get_formatted_line_subtotal( $item : object [, $tax_display : string = '' ] ) : string
Parameters
$item : object

Item to get total from.

$tax_display : string = ''

Incl or excl tax display mode.

Return values
string

get_formatted_order_total()

Gets order total - formatted for display.

public get_formatted_order_total( ) : string
Return values
string

get_subtotal_to_display()

Gets subtotal - subtotal is shown before discounts, but with localised taxes.

public get_subtotal_to_display( [ $compound : bool = false ] [, $tax_display : string = '' ] ) : string
Parameters
$compound : bool = false

(default: false).

$tax_display : string = ''

(default: the tax_display_cart value).

Return values
string

get_shipping_to_display()

Gets shipping (formatted).

public get_shipping_to_display( [ $tax_display : string = '' ] ) : string
Parameters
$tax_display : string = ''

Excl or incl tax display mode.

Return values
string

get_discount_to_display()

Get the discount amount (formatted).

public get_discount_to_display( [ $tax_display : string = '' ] ) : string
Parameters
$tax_display : string = ''

Excl or incl tax display mode.

Tags
since
Return values
string

add_order_item_totals_subtotal_row()

Add total row for subtotal.

protected add_order_item_totals_subtotal_row( &$total_rows : array , $tax_display : string ) : mixed
Parameters
$total_rows : array

Reference to total rows array.

$tax_display : string

Excl or incl tax display mode.

Return values
mixed

add_order_item_totals_discount_row()

Add total row for discounts.

protected add_order_item_totals_discount_row( &$total_rows : array , $tax_display : string ) : mixed
Parameters
$total_rows : array

Reference to total rows array.

$tax_display : string

Excl or incl tax display mode.

Return values
mixed

add_order_item_totals_shipping_row()

Add total row for shipping.

protected add_order_item_totals_shipping_row( &$total_rows : array , $tax_display : string ) : mixed
Parameters
$total_rows : array

Reference to total rows array.

$tax_display : string

Excl or incl tax display mode.

Return values
mixed

add_order_item_totals_fee_rows()

Add total row for fees.

protected add_order_item_totals_fee_rows( &$total_rows : array , $tax_display : string ) : mixed
Parameters
$total_rows : array

Reference to total rows array.

$tax_display : string

Excl or incl tax display mode.

Return values
mixed

add_order_item_totals_tax_rows()

Add total row for taxes.

protected add_order_item_totals_tax_rows( &$total_rows : array , $tax_display : string ) : mixed
Parameters
$total_rows : array

Reference to total rows array.

$tax_display : string

Excl or incl tax display mode.

Return values
mixed

add_order_item_totals_total_row()

Add total row for grand total.

protected add_order_item_totals_total_row( &$total_rows : array , $tax_display : string ) : mixed
Parameters
$total_rows : array

Reference to total rows array.

$tax_display : string

Excl or incl tax display mode.

Return values
mixed

get_order_item_totals()

Get totals for display on pages and in emails.

public get_order_item_totals( [ $tax_display : mixed = '' ] ) : array
Parameters
$tax_display : mixed = ''

Excl or incl tax display mode.

Return values
array

has_status()

Checks the order status against a passed in status.

public has_status( $status : array|string ) : bool
Parameters
$status : array|string

Status to check.

Return values
bool

has_shipping_method()

Check whether this order has a specific shipping method or not.

public has_shipping_method( $method_id : string ) : bool
Parameters
$method_id : string

Method ID to check.

Return values
bool

has_free_item()

Returns true if the order contains a free product.

public has_free_item( ) : bool
Tags
since
Return values
bool

get_rounded_items_total()

Return rounded total based on settings. Will be used by Cart and Orders.

public static get_rounded_items_total( $values : array ) : float|int
Parameters
$values : array

Values to round. Should be with precision.

Tags
since
Return values
float|int

Appropriately rounded value.

round_item_subtotal()

Apply rounding to item subtotal before summing.

public static round_item_subtotal( $value : float ) : float
Parameters
$value : float

Item subtotal value.

Tags
since
Return values
float

round_at_subtotal()

Should always round at subtotal?

protected static round_at_subtotal( ) : bool
Tags
since
Return values
bool

round_line_tax()

Apply rounding to an array of taxes before summing. Rounds to store DP setting, ignoring precision.

protected static round_line_tax( $value : float [, $in_cents : bool = true ] ) : float
Parameters
$value : float

Tax value.

$in_cents : bool = true

Whether precision of value is in cents.

Tags
since
Return values
float

add_coupon()

Add coupon code to the order.

public add_coupon( [ $code : string|array = array() ] , $discount : int , $discount_tax : int ) : int
Parameters
$code : string|array = array()
$discount : int

tax amount.

$discount_tax : int

amount.

Tags
throws
Return values
int

order item ID

add_tax()

Add a tax row to the order.

public add_tax( $tax_rate_id : int , $tax_amount : int , $shipping_tax_amount : int ) : int
Parameters
$tax_rate_id : int
$tax_amount : int

amount of tax.

$shipping_tax_amount : int

shipping amount.

Tags
throws
Return values
int

order item ID

add_shipping()

Add a shipping row to the order.

public add_shipping( $shipping_rate : mixed ) : int
Parameters
$shipping_rate : mixed
Tags
throws
Return values
int

order item ID

add_fee()

Add a fee to the order.

public add_fee( $fee : object ) : int

Order must be saved prior to adding items.

Fee is an amount of money charged for a particular piece of work or for a particular right or service, and not supposed to be negative.

Parameters
$fee : object

Fee data.

Tags
throws
Return values
int

Updated order item ID.

update_product()

Update a line item for the order.

public update_product( $item : object|int , $product : WC_Product , $args : array ) : int

Note this does not update order totals.

Parameters
$item : object|int

order item ID or item object.

$product : WC_Product
$args : array

data to update.

Tags
throws
Return values
int

updated order item ID

update_coupon()

Update coupon for order. Note this does not update order totals.

public update_coupon( $item : object|int , $args : array ) : int
Parameters
$item : object|int
$args : array
Tags
throws
Return values
int

updated order item ID

update_shipping()

Update shipping method for order.

public update_shipping( $item : object|int , $args : array ) : int

Note this does not update the order total.

Parameters
$item : object|int
$args : array
Tags
throws
Return values
int

updated order item ID

update_fee()

Update fee for order.

public update_fee( $item : object|int , $args : array ) : int

Note this does not update order totals.

Parameters
$item : object|int
$args : array
Tags
throws
Return values
int

updated order item ID

update_tax()

Update tax line on order.

public update_tax( $item : object|int , $args : array ) : int

Note this does not update order totals.

Parameters
$item : object|int
$args : array
Tags
since
throws
Return values
int

updated order item ID

get_product_from_item()

Get a product (either product or variation).

public get_product_from_item( $item : object ) : WC_Product|bool
Parameters
$item : object
Tags
deprecated
Return values
WC_Product|bool

set_address()

Set the customer address.

public set_address( $address : array [, $type : string = 'billing' ] ) : mixed
Parameters
$address : array

Address data.

$type : string = 'billing'

billing or shipping.

Return values
mixed

legacy_set_total()

Set an order total.

public legacy_set_total( $amount : float [, $total_type : string = 'total' ] ) : bool
Parameters
$amount : float
$total_type : string = 'total'
Return values
bool

__isset()

Magic __isset method for backwards compatibility. Handles legacy properties which could be accessed directly in the past.

public __isset( $key : string ) : bool
Parameters
$key : string
Return values
bool

__get()

Magic __get method for backwards compatibility.

public __get( $key : string ) : mixed
Parameters
$key : string
Return values
mixed

has_meta()

has_meta function for order items. This is different to the WC_Data version and should be removed in future versions.

public has_meta( $order_item_id : int ) : array
Parameters
$order_item_id : int
Tags
deprecated
Return values
array

of meta data.

display_item_meta()

Display meta data belonging to an item.

public display_item_meta( $item : array ) : mixed
Parameters
$item : array
Return values
mixed

display_item_downloads()

Display download links for an order item.

public display_item_downloads( $item : array ) : mixed
Parameters
$item : array
Return values
mixed

get_download_url()

Get the Download URL.

public get_download_url( $product_id : int , $download_id : int ) : string
Parameters
$product_id : int
$download_id : int
Return values
string

get_item_downloads()

Get the downloadable files for an item in this order.

public get_item_downloads( $item : array ) : array
Parameters
$item : array
Return values
array

get_total_shipping()

Gets shipping total. Alias of WC_Order::get_shipping_total().

public get_total_shipping( ) : float
Tags
deprecated

since this is an alias only.

Return values
float

get_item_meta()

Get order item meta.

public get_item_meta( $order_item_id : mixed [, $key : string = '' ] [, $single : bool = false ] ) : array|string
Parameters
$order_item_id : mixed
$key : string = ''

(default: '')

$single : bool = false

(default: false)

Tags
deprecated
Return values
array|string

get_item_meta_array()

Get all item meta data in array format in the order it was saved. Does not group meta by key like get_item_meta().

public get_item_meta_array( $order_item_id : mixed ) : array
Parameters
$order_item_id : mixed
Return values
array

of objects

get_used_coupons()

Get coupon codes only.

public get_used_coupons( ) : array
Tags
deprecated
  • Replaced with better named method to reflect the actual data being returned.
Return values
array

expand_item_meta()

Expand item meta into the $item array.

public expand_item_meta( $item : array ) : array
Parameters
$item : array

before expansion.

Tags
deprecated

Item meta no longer expanded due to new order item classes. This function now does nothing to avoid data breakage.

Return values
array

init()

Load the order object. Called from the constructor.

protected init( $order : int|object|WC_Order ) : mixed
Parameters
$order : int|object|WC_Order

Order to init.

Tags
deprecated

Logic moved to constructor

Return values
mixed

get_order()

Gets an order from the database.

public get_order( $id : int ) : bool
Parameters
$id : int

(default: 0).

Tags
deprecated
Return values
bool

populate()

Populates an order from the loaded post data.

public populate( $result : mixed ) : mixed
Parameters
$result : mixed
Tags
deprecated
Return values
mixed

cancel_order()

Cancel the order and restore the cart (before payment).

public cancel_order( [ $note : string = '' ] ) : mixed
Parameters
$note : string = ''

(default: '') Optional note to add.

Tags
deprecated

Moved to event handler.

Return values
mixed

record_product_sales()

Record sales.

public record_product_sales( ) : mixed
Tags
deprecated
Return values
mixed

increase_coupon_usage_counts()

Increase applied coupon counts.

public increase_coupon_usage_counts( ) : mixed
Tags
deprecated
Return values
mixed

decrease_coupon_usage_counts()

Decrease applied coupon counts.

public decrease_coupon_usage_counts( ) : mixed
Tags
deprecated
Return values
mixed

reduce_order_stock()

Reduce stock levels for all line items in the order.

public reduce_order_stock( ) : mixed
Tags
deprecated
Return values
mixed

send_stock_notifications()

Send the stock notifications.

public send_stock_notifications( $product : , $new_stock : , $qty_ordered : ) : mixed
Parameters
$product :
$new_stock :
$qty_ordered :
Tags
deprecated

No longer needs to be called directly.

Return values
mixed

email_order_items_table()

Output items for display in html emails.

public email_order_items_table( [ $args : array = array() ] ) : string
Parameters
$args : array = array()

Items args.

Tags
deprecated

Moved to template functions.

Return values
string

get_order_currency()

Get currency.

public get_order_currency( ) : mixed
Tags
deprecated
Return values
mixed

__sleep()

Only store the object ID to avoid serializing the data object instance.

public __sleep( ) : array
Return values
array

__wakeup()

Re-run the constructor with the object ID.

public __wakeup( ) : mixed

If the object no longer exists, remove the ID.

Return values
mixed

__clone()

When the object is cloned, make sure meta is duplicated correctly.

public __clone( ) : mixed
Tags
since
Return values
mixed

get_data_store()

Get the data store.

public get_data_store( ) : object
Tags
since
Return values
object

get_id()

Returns the unique ID for this object.

public get_id( ) : int
Tags
since
Return values
int

delete()

Delete an object, set the ID to 0, and return result.

public delete( [ $force_delete : bool = false ] ) : bool
Parameters
$force_delete : bool = false

Should the date be deleted permanently.

Tags
since
Return values
bool

result

__toString()

Change data to JSON format.

public __toString( ) : string
Tags
since
Return values
string

Data in JSON format.

get_data_keys()

Returns array of expected data keys for this object.

public get_data_keys( ) : array
Tags
since
Return values
array

get_extra_data_keys()

Returns all "extra" data keys for an object (for sub objects like product types).

public get_extra_data_keys( ) : array
Tags
since
Return values
array

filter_null_meta()

Filter null meta values from array.

protected filter_null_meta( $meta : mixed ) : bool
Parameters
$meta : mixed

Meta value to check.

Tags
since
Return values
bool

get_meta_data()

Get All Meta Data.

public get_meta_data( ) : array
Tags
since
Return values
array

of objects.

is_internal_meta_key()

Check if the key is an internal one.

protected is_internal_meta_key( $key : string ) : bool
Parameters
$key : string

Key to check.

Tags
since
Return values
bool

true if it's an internal key, false otherwise

get_meta()

Get Meta Data by Key.

public get_meta( [ $key : string = '' ] [, $single : bool = true ] [, $context : string = 'view' ] ) : mixed
Parameters
$key : string = ''

Meta Key.

$single : bool = true

return first found meta with key, or all with $key.

$context : string = 'view'

What the value is for. Valid values are view and edit.

Tags
since
Return values
mixed

meta_exists()

See if meta data exists, since get_meta always returns a '' or array().

public meta_exists( [ $key : string = '' ] ) : bool
Parameters
$key : string = ''

Meta Key.

Tags
since
Return values
bool

set_meta_data()

Set all meta data from array.

public set_meta_data( $data : array ) : mixed
Parameters
$data : array

Key/Value pairs.

Tags
since
Return values
mixed

add_meta_data()

Add meta data.

public add_meta_data( $key : string , $value : string|array [, $unique : bool = false ] ) : mixed
Parameters
$key : string

Meta key.

$value : string|array

Meta value.

$unique : bool = false

Should this be a unique key?.

Tags
since
Return values
mixed

update_meta_data()

Update meta data by key or ID, if provided.

public update_meta_data( $key : string , $value : string|array , $meta_id : int ) : mixed
Parameters
$key : string

Meta key.

$value : string|array

Meta value.

$meta_id : int

Meta ID.

Tags
since
Return values
mixed

delete_meta_data()

Delete meta data.

public delete_meta_data( $key : string ) : mixed
Parameters
$key : string

Meta key.

Tags
since
Return values
mixed

delete_meta_data_by_mid()

Delete meta data.

public delete_meta_data_by_mid( $mid : int ) : mixed
Parameters
$mid : int

Meta ID.

Tags
since
Return values
mixed

maybe_read_meta_data()

Read meta data if null.

protected maybe_read_meta_data( ) : mixed
Tags
since
Return values
mixed

read_meta_data()

Read Meta Data from the database. Ignore any internal properties.

public read_meta_data( [ $force_read : bool = false ] ) : mixed

Uses it's own caches because get_metadata does not provide meta_ids.

Parameters
$force_read : bool = false

True to force a new DB read (and update cache).

Tags
since
Return values
mixed

save_meta_data()

Update Meta Data in the database.

public save_meta_data( ) : mixed
Tags
since
Return values
mixed

set_id()

Set ID.

public set_id( $id : int ) : mixed
Parameters
$id : int

ID.

Tags
since
Return values
mixed

set_defaults()

Set all props to default values.

public set_defaults( ) : mixed
Tags
since
Return values
mixed

set_object_read()

Set object read property.

public set_object_read( [ $read : bool = true ] ) : mixed
Parameters
$read : bool = true

Should read?.

Tags
since
Return values
mixed

get_object_read()

Get object read property.

public get_object_read( ) : bool
Tags
since
Return values
bool

set_props()

Set a collection of props in one go, collect any errors, and return the result.

public set_props( $props : array [, $context : string = 'set' ] ) : bool|WP_Error

Only sets using public methods.

Parameters
$props : array

Key value pairs to set. Key is the prop and should map to a setter function name.

$context : string = 'set'

In what context to run this.

Tags
since
Return values
bool|WP_Error

set_prop()

Sets a prop for a setter method.

protected set_prop( $prop : string , $value : mixed ) : mixed

This stores changes in a special array so we can track what needs saving the the DB later.

Parameters
$prop : string

Name of prop to set.

$value : mixed

Value of the prop.

Tags
since
Return values
mixed

get_changes()

Return data changes only.

public get_changes( ) : array
Tags
since
Return values
array

apply_changes()

Merge changes with data and clear.

public apply_changes( ) : mixed
Tags
since
Return values
mixed

get_hook_prefix()

Prefix for action and filter hooks on data.

protected get_hook_prefix( ) : string
Tags
since
Return values
string

get_prop()

Gets a prop for a getter method.

protected get_prop( $prop : string [, $context : string = 'view' ] ) : mixed

Gets the value from either current pending changes, or the data itself. Context controls what happens to the value before it's returned.

Parameters
$prop : string

Name of prop to get.

$context : string = 'view'

What the value is for. Valid values are view and edit.

Tags
since
Return values
mixed

set_date_prop()

Sets a date prop whilst handling formatting and datetime objects.

protected set_date_prop( $prop : string , $value : string|int ) : mixed
Parameters
$prop : string

Name of prop to set.

$value : string|int

Value of the prop.

Tags
since
Return values
mixed

error()

When invalid data is found, throw an exception unless reading from the DB.

protected error( $code : string , $message : string [, $http_status_code : int = 400 ] [, $data : array = array() ] ) : mixed
Parameters
$code : string

Error code.

$message : string

Error message.

$http_status_code : int = 400

HTTP status code.

$data : array = array()

Extra error data.

Tags
throws

Data Exception.

since
Return values
mixed
Back to the top