WordPress at Your Fingertips
function is not described

WC_Order::needs_processing() public WC 3.0.0

See if the order needs processing before it can be completed.

Orders which only contain virtual, downloadable items do not need admin intervention.

Uses a transient so these calls are not repeated multiple times, and because once the order is processed this code/transient does not need to persist.

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

Return

true|false.

Usage

$WC_Order = new WC_Order();
$WC_Order->needs_processing();

Changelog

Since 3.0.0 Introduced.

Code of WC_Order::needs_processing() WC 5.6.0

public function needs_processing() {
	$transient_name   = 'wc_order_' . $this->get_id() . '_needs_processing';
	$needs_processing = get_transient( $transient_name );

	if ( false === $needs_processing ) {
		$needs_processing = 0;

		if ( count( $this->get_items() ) > 0 ) {
			foreach ( $this->get_items() as $item ) {
				if ( $item->is_type( 'line_item' ) ) {
					$product = $item->get_product();

					if ( ! $product ) {
						continue;
					}

					$virtual_downloadable_item = $product->is_downloadable() && $product->is_virtual();

					if ( apply_filters( 'woocommerce_order_item_needs_processing', ! $virtual_downloadable_item, $product, $this->get_id() ) ) {
						$needs_processing = 1;
						break;
					}
				}
			}
		}

		set_transient( $transient_name, $needs_processing, DAY_IN_SECONDS );
	}

	return 1 === absint( $needs_processing );
}