Automattic\WooCommerce\Internal\Fulfillments
FulfillmentsSettings::auto_fulfill_items_on_completed
Automatically fulfill items in the order for orders that skip the processing state.
Method of the class: FulfillmentsSettings{}
No Hooks.
Returns
null. Nothing (null).
Usage
$FulfillmentsSettings = new FulfillmentsSettings(); $FulfillmentsSettings->auto_fulfill_items_on_completed( $order_id, $order ): void;
- $order_id(int) (required)
- The ID of the order being created.
- $order(WC_Order) (required)
- The order object.
FulfillmentsSettings::auto_fulfill_items_on_completed() FulfillmentsSettings::auto fulfill items on completed code WC 10.3.3
public function auto_fulfill_items_on_completed( int $order_id, $order ): void {
$order = $order instanceof WC_Order ? $order : wc_get_order( $order_id );
if ( ! $order || empty( $order->get_items() ) ) {
return;
}
// If auto-fulfill already processed, skip.
if ( $order->get_meta( '_auto_fulfill_processed', true ) ) {
return;
}
// If fulfillments already exist, skip auto-fulfillment.
$fulfillments = wc_get_container()->get( FulfillmentsDataStore::class )->read_fulfillments( \WC_Order::class, (string) $order_id );
if ( ! empty( $fulfillments ) ) {
return;
}
// Auto-fulfill items.
$this->auto_fulfill_items_on_processing( $order_id, $order );
}