Automattic\WooCommerce\Internal\Admin\Orders

EditLock::check_locked_orders_ajax()publicWC 1.0

Hooked to heartbeat_received the orders screen to refresh the locked status of orders in the list table.

Метод класса: EditLock{}

Хуков нет.

Возвращает

Массив. Response to be sent.

Использование

$EditLock = new EditLock();
$EditLock->check_locked_orders_ajax( $response, $data );
$response(массив) (обязательный)
The heartbeat response to be sent.
$data(массив) (обязательный)
Data sent through the heartbeat.

Код EditLock::check_locked_orders_ajax() WC 9.3.3

public function check_locked_orders_ajax( $response, $data ) {
	if ( empty( $data['wc-check-locked-orders'] ) || ! is_array( $data['wc-check-locked-orders'] ) ) {
		return $response;
	}

	$response['wc-check-locked-orders'] = array();

	$order_ids = array_unique( array_map( 'absint', $data['wc-check-locked-orders'] ) );
	foreach ( $order_ids as $order_id ) {
		$order = wc_get_order( $order_id );
		if ( ! $order ) {
			continue;
		}

		if ( ! $this->is_locked_by_another_user( $order ) || ( ! current_user_can( get_post_type_object( $order->get_type() )->cap->edit_post, $order->get_id() ) && ! current_user_can( 'manage_woocommerce' ) ) ) {
			continue;
		}

		$response['wc-check-locked-orders'][ $order_id ] = true;
	}

	return $response;
}