WordPress at Your Fingertips
function is not described


Checkout::is_valid_draft_order() private WC 1.0

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

{} It's a method of the class: Checkout{}

No Hooks.


true|false. Whether the order is valid as a draft order.


// private - for code of main (parent) class only
$result = $this->is_valid_draft_order( $order_object );
$order_object(\WC_Order) (required)
Order object to check.

Code of Checkout::is_valid_draft_order() WC 5.7.1

private function is_valid_draft_order( $order_object ) {
	if ( ! $order_object instanceof \WC_Order ) {
		return false;

	// Draft orders are okay.
	if ( $order_object->has_status( 'checkout-draft' ) ) {
		return true;

	// Pending and failed orders can be retried if the cart hasn't changed.
	if ( $order_object->needs_payment() && $order_object->has_cart_hash( wc()->cart->get_cart_hash() ) ) {
		return true;

	return false;