Automattic\WooCommerce\Admin\Features\Fulfillments

FulfillmentUtils::resolve_provider_namepublic staticWC 10.7.0

Resolve the provider name for a fulfillment.

For custom providers ("other"), the display name from _provider_name meta is used. For known providers, the slug from _shipment_provider meta is preferred, but the display name is used as a fallback when the slug is empty (e.g., when auto-lookup identified the provider but did not set the slug).

Method of the class: FulfillmentUtils{}

No Hooks.

Returns

String. The resolved provider name.

Usage

$result = FulfillmentUtils::resolve_provider_name( $fulfillment ): string;
$fulfillment(Fulfillment) (required)
The fulfillment object.

Changelog

Since 10.7.0 Introduced.

FulfillmentUtils::resolve_provider_name() code WC 10.7.0

public static function resolve_provider_name( Fulfillment $fulfillment ): string {
	$shipment_provider = $fulfillment->get_shipment_provider() ?? '';
	$provider_name     = $fulfillment->get_meta( '_provider_name', true );
	$provider_name     = ! empty( $provider_name ) ? (string) $provider_name : '';

	if ( 'other' === $shipment_provider ) {
		return $provider_name;
	}

	return ! empty( $shipment_provider ) ? $shipment_provider : $provider_name;
}