WooCommerce Code Reference

DraftOrderTrait

DraftOrderTrait

Shared functionality for getting and setting draft order IDs from session.

Table of Contents

get_draft_order()  : WC_Order|null
Uses the draft order ID to return an order object, if valid.
get_draft_order_id()  : int
Gets draft order data from the customer session.
is_valid_draft_order()  : bool
Whether the passed argument is a draft order or an order that is pending/failed and the cart hasn't changed.
set_draft_order_id()  : mixed
Updates draft order data in the customer session.

Methods

is_valid_draft_order()

Whether the passed argument is a draft order or an order that is pending/failed and the cart hasn't changed.

protected is_valid_draft_order(WC_Order $order_object) : bool
Parameters
$order_object : WC_Order

Order object to check.

Return values
boolWhether the order is valid as a draft order.

set_draft_order_id()

Updates draft order data in the customer session.

protected set_draft_order_id(int $order_id) : mixed
Parameters
$order_id : int

Draft order ID.

Return values
mixed