Automattic\WooCommerce\Admin\Features\Fulfillments

FulfillmentsTracker::determine_tracking_entry_methodpublic staticWC 10.7.0

Determine the tracking entry method from the request source and fulfillment meta data.

Maps the shipping option meta value to the standardized entry_method values expected by the fulfillment_tracking_added event. Whether the provider is custom or native is tracked separately via the is_custom_provider property on the event.

  • "ui_auto_lookup" : Tracking number was auto-detected via the lookup API.
  • "ui_manual" : Merchant manually selected or entered a provider.
  • "api" : Tracking was added via the REST API (not through the UI).

Method of the class: FulfillmentsTracker{}

No Hooks.

Returns

String. The entry method identifier.

Usage

$result = FulfillmentsTracker::determine_tracking_entry_method( $source, $shipping_option ): string;
$source(string) (required)
The request source ("fulfillments_modal" or "api").
$shipping_option(string) (required)
The shipping option meta value ("tracking-number", "manual-entry", or "no-info").

Changelog

Since 10.7.0 Introduced.

FulfillmentsTracker::determine_tracking_entry_method() code WC 10.7.0

public static function determine_tracking_entry_method( string $source, string $shipping_option ): string {
	if ( 'fulfillments_modal' !== $source ) {
		return 'api';
	}

	if ( 'tracking-number' === $shipping_option ) {
		return 'ui_auto_lookup';
	}

	if ( 'manual-entry' === $shipping_option ) {
		return 'ui_manual';
	}

	return 'api';
}