Automattic\WooCommerce\Checkout\Helpers

ReserveStock::get_current_shopper_stock_holding_order_ids │ private │ WC 1.0

Returns stock-holding order ids associated with the current shopper.

Includes orders recorded by the current session and unpaid orders belonging to the signed-in customer. Ownership is never inferred from anything a shopper can type, such as the billing email.

Method of the class: ReserveStock{}

No Hooks.

Returns

int[].

Usage

// private - for code of main (parent) class only
$result = $this->get_current_shopper_stock_holding_order_ids(): array;

ReserveStock::get_current_shopper_stock_holding_order_ids() code WC 11.3.0

private function get_current_shopper_stock_holding_order_ids(): array {
	$session = WC()->session;

	// In the admin, WP-CLI and cron there is no shopper and WC()->session is
	// not initialised, so nothing is ever treated as the requester's own hold.
	if ( ! $session instanceof \WC_Session ) {
		return array();
	}

	$order_ids = $this->get_session_stock_holding_order_ids( $session );

	$customer_id = get_current_user_id();

	if ( $customer_id ) {
		$order_ids = array_merge( $order_ids, $this->get_potential_stock_holding_order_ids_for_customer( $customer_id ) );
	}

	return array_values( array_filter( array_unique( $order_ids ) ) );
}