Automattic\WooCommerce\Admin\Features\Fulfillments

FulfillmentsManager::delete_order_fulfillmentspublicWC 10.7.0

Delete all fulfillment records for an order that is being permanently deleted.

Does nothing if the given ID does not correspond to a valid order type. Exceptions are caught and logged; this method never throws.

Method of the class: FulfillmentsManager{}

No Hooks.

Returns

null. Nothing (null).

Usage

$FulfillmentsManager = new FulfillmentsManager();
$FulfillmentsManager->delete_order_fulfillments( $order_id ): void;
$order_id(int) (required)
The ID of the order being deleted.

Changelog

Since 10.7.0 Introduced.

FulfillmentsManager::delete_order_fulfillments() code WC 10.9.4

public function delete_order_fulfillments( int $order_id ): void {
	try {
		if ( ! OrderUtil::is_order( $order_id, wc_get_order_types() ) ) {
			return;
		}

		/**
		 * Fulfillments data store.
		 *
		 * @var \Automattic\WooCommerce\Admin\Features\Fulfillments\DataStore\FulfillmentsDataStore $fulfillments_data_store
		 */
		$fulfillments_data_store = \WC_Data_Store::load( 'order-fulfillment' );
		$fulfillments_data_store->delete_by_entity( WC_Order::class, (string) $order_id );
	} catch ( \Throwable $e ) {
		wc_get_logger()->error(
			sprintf( 'Failed to delete fulfillments for order %d: %s', $order_id, $e->getMessage() ),
			array( 'source' => 'fulfillments' )
		);
	}
}