Automattic\WooCommerce\Internal\Admin\Settings

PaymentsProviders::order_map_add_gatewaypublicWC 1.0

Add a new gateway to an order map with offline-awareness.

If the offline payment methods group is the last non-offline, non-suggestion entry, the gateway is placed above it. Otherwise, it is appended at the end.

This is the single source of truth for new gateway placement logic, used by both the display path (Payments) and the persistence path (enhance_order_map).

Method of the class: PaymentsProviders{}

No Hooks.

Returns

Array. The updated order map.

Usage

$PaymentsProviders = new PaymentsProviders();
$PaymentsProviders->order_map_add_gateway( $order_map, $id ): array;
$order_map(array) (required)
The payment providers order map.
$id(string) (required)
The gateway ID to add.

PaymentsProviders::order_map_add_gateway() code WC 10.7.0

public function order_map_add_gateway( array $order_map, string $id ): array {
	if ( $this->is_offline_group_last( $order_map ) ) {
		return Utils::order_map_add_at_order(
			$order_map,
			$id,
			$order_map[ self::OFFLINE_METHODS_ORDERING_GROUP ]
		);
	}

	return Utils::order_map_add_at_order( $order_map, $id, empty( $order_map ) ? 0 : max( $order_map ) + 1 );
}