WooCommerce Code Reference

WC_Order_Factory
in package

Order factory class

Table of Contents

get_class_names_for_order_ids()  : array<string|int, mixed>
Gets the class name bunch of order instances should have based on their IDs.
get_order()  : WC_Order|bool
Get order.
get_order_id()  : int|bool
Get the order ID depending on what was passed.
get_order_item()  : WC_Order_Item|false
Get order item.
get_orders()  : mixed
Get multiple orders (by ID).
get_class_name_for_order_id()  : string
Gets the class name an order instance should have based on its ID.
get_global_order_id()  : false|int
Try to determine the current order ID based on available global state.

Methods

get_class_names_for_order_ids()

Gets the class name bunch of order instances should have based on their IDs.

public static get_class_names_for_order_ids(array<string|int, mixed> $order_ids) : array<string|int, mixed>
Parameters
$order_ids : array<string|int, mixed>

Order IDs to get the class name for.

Return values
array<string|int, mixed>Array of order_id => class_name.

get_order_id()

Get the order ID depending on what was passed.

public static get_order_id(mixed $order) : int|bool
Parameters
$order : mixed

Order data to convert to an ID.

Tags
since
3.0.0
Return values
int|boolfalse on failure

get_orders()

Get multiple orders (by ID).

public static get_orders([mixed $order_ids = array() ][, bool $skip_invalid = false ]) : mixed
Parameters
$order_ids : mixed = array()

Array of order IDs to get.

$skip_invalid : bool = false

(default: false) TRUE if invalid IDs or orders should be ignored.

Tags
throws
Exception

When an invalid order is found.

Return values
mixed

get_class_name_for_order_id()

Gets the class name an order instance should have based on its ID.

private static get_class_name_for_order_id(int $order_id) : string
Parameters
$order_id : int

The order ID.

Tags
since
6.9.0
Return values
stringThe class name or FALSE if the class does not exist.

get_global_order_id()

Try to determine the current order ID based on available global state.

private static get_global_order_id() : false|int
Return values
false|int