Automattic\WooCommerce\Admin\Features\Fulfillments

FulfillmentsManager::update_fulfillment_statusprivateWC 1.0

Update the fulfillment status for the order.

Method of the class: FulfillmentsManager{}

No Hooks.

Returns

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->update_fulfillment_status( $order, $fulfillments );
$order(WC_Order) (required)
The order object.
$fulfillments(array)
The fulfillments data store.

This method updates the fulfillment status for the order based on the fulfillments data store.
Default: array()

FulfillmentsManager::update_fulfillment_status() code WC 11.0.1

private function update_fulfillment_status( $order, $fulfillments = array() ) {
	$old_status = FulfillmentUtils::get_order_fulfillment_status( $order );
	$new_status = FulfillmentUtils::calculate_order_fulfillment_status( $order, $fulfillments );

	if ( 'no_fulfillments' === $new_status ) {
		$order->delete_meta_data( '_fulfillment_status' );
	} else {
		$order->update_meta_data( '_fulfillment_status', $new_status );
	}

	$order->save();

	if ( $old_status !== $new_status && isset( $this->fulfillment_order_notes ) ) {
		$this->fulfillment_order_notes->add_order_fulfillment_status_changed_note( $order, $old_status, $new_status );
	}
}