Automattic\WooCommerce\Internal\Fulfillments
FulfillmentUtils::calculate_order_fulfillment_status
Get the fulfillment status of the entity. This runs like a computed property, where it checks the fulfillment status of each fulfillment attached to the order, and computes the overall fulfillment status of the order.
Method of the class: FulfillmentUtils{}
Hooks from the method
Returns
String. The fulfillment status.
Usage
$result = FulfillmentUtils::calculate_order_fulfillment_status( $order, $fulfillments ): string;
- $order(WC_Order) (required)
- The order object.
- $fulfillments(array)
- An array of fulfillments to check.
Default: array()
FulfillmentUtils::calculate_order_fulfillment_status() FulfillmentUtils::calculate order fulfillment status code WC 10.3.3
public static function calculate_order_fulfillment_status( WC_Order $order, $fulfillments = array() ): string {
$has_fulfillments = ! empty( $fulfillments );
if ( $has_fulfillments ) {
$pending_items = self::get_pending_items( $order, $fulfillments );
$all_fulfilled = true;
$some_fulfilled = false;
foreach ( $fulfillments as $fulfillment ) {
if ( ! $fulfillment->get_is_fulfilled() ) {
$all_fulfilled = false;
} else {
$some_fulfilled = true;
}
}
if ( $all_fulfilled && empty( $pending_items ) ) {
$status = 'fulfilled';
} elseif ( $some_fulfilled ) {
$status = 'partially_fulfilled';
} else {
$status = 'unfulfilled';
}
} else {
$status = 'no_fulfillments';
}
/**
* This filter allows plugins to modify the fulfillment status of an order.
*
* @since 10.1.0
*
* @param string $status The default fulfillment status.
* @param WC_Order $order The order object.
* @param array $fulfillments An array of fulfillments for the order.
*/
return apply_filters(
'woocommerce_fulfillment_calculate_order_fulfillment_status',
$status,
$order,
$fulfillments
);
}