WC_Order::needs_processing
See if the order needs processing before it can be completed.
Orders which only contain virtual, downloadable items do not need admin intervention.
Method of the class: WC_Order{}
Hooks from the method
Returns
true|false.
Usage
$WC_Order = new WC_Order(); $WC_Order->needs_processing();
Changelog
| Since 3.0.0 | Introduced. |
| Since 10.8.0 | the method no longer uses transients. |
WC_Order::needs_processing() WC Order::needs processing code WC 10.8.1
public function needs_processing() {
$order_id = $this->get_id();
$cache_key = 'order-needs-processing-' . $order_id;
$needs_processing = wp_cache_get( $cache_key, 'orders' );
if ( false === $needs_processing ) {
$needs_processing = 0;
$line_items = $this->get_items();
if ( count( $line_items ) > 0 ) {
foreach ( $line_items as $item ) {
if ( $item->is_type( 'line_item' ) ) {
$product = $item->get_product();
if ( $product ) {
$virtual_downloadable_item = $product->is_downloadable() && $product->is_virtual();
/**
* Filters whether an order line item requires processing. By default, only
* virtual downloadable items do not require processing; all other items do.
*
* @since 2.7.0
*
* @param bool $needs_processing
* @param \WC_Product $product
* @param int $order_id
* @return bool
*/
$custom_needs_processing = (bool) apply_filters( 'woocommerce_order_item_needs_processing', ! $virtual_downloadable_item, $product, $order_id );
if ( $custom_needs_processing ) {
$needs_processing = 1;
break;
}
}
}
}
}
wp_cache_set( $cache_key, $needs_processing, 'orders', DAY_IN_SECONDS );
}
return 1 === absint( $needs_processing );
}