WooCommerce Code Reference

OrderAwareControllerTrait

Trait to contain shared methods for reports Controllers that use order and orders statuses.

If your analytics controller needs to work with orders, you will most probably need to use at least {@see get_order_statuses()} to filter only "actionable" statuses to produce consistent results among other analytics.

Tags
see
GenericController

Table of Contents

get_order_statuses()  : array<string|int, mixed>
Get order statuses without prefixes.
get_order_number()  : string|null
Get the order number for an order. If no filter is present for `woocommerce_order_number`, we can just return the ID.
get_total_formatted()  : string|null
Get the order total with the related currency formatting.
is_valid_order()  : bool
Whether the order is valid.

Methods

get_order_statuses()

Get order statuses without prefixes.

public static get_order_statuses() : array<string|int, mixed>

Includes unregistered statuses that have been marked "actionable".

Return values
array<string|int, mixed>

get_order_number()

Get the order number for an order. If no filter is present for `woocommerce_order_number`, we can just return the ID.

protected get_order_number(int $order_id) : string|null

Returns the parent order number if the order is actually a refund.

Parameters
$order_id : int

Order ID.

Return values
string|nullThe Order Number or null if the order doesn't exist.

get_total_formatted()

Get the order total with the related currency formatting.

protected get_total_formatted(int $order_id) : string|null

Returns the parent order total if the order is actually a refund.

Parameters
$order_id : int

Order ID.

Return values
string|nullThe Order Number or null if the order doesn't exist.

is_valid_order()

Whether the order is valid.

protected is_valid_order(bool|WC_Order|WC_Order_Refund $order) : bool
Parameters
$order : bool|WC_Order|WC_Order_Refund

Order object.

Return values
boolTrue if the order is valid, false otherwise.