Automattic\WooCommerce\Internal\Admin\Settings
PaymentProviders::payment_providers_order_map_apply_mappings()
Apply order mappings to a base payment providers order map.
Метод класса: PaymentProviders{}
Хуков нет.
Возвращает
Массив
. The updated base order map, normalized.
Использование
// private - только в коде основоного (родительского) класса $result = $this->payment_providers_order_map_apply_mappings( $base_map, $new_mappings ): array;
- $base_map(массив) (обязательный)
- The base order map.
- $new_mappings(массив) (обязательный)
- The order mappings to apply. This can be a full or partial list of the base one, but it can also contain (only) new provider IDs and their orders.
Код PaymentProviders::payment_providers_order_map_apply_mappings() PaymentProviders::payment providers order map apply mappings WC 9.6.1
private function payment_providers_order_map_apply_mappings( array $base_map, array $new_mappings ): array { // Sanity checks. // Remove any null or non-integer values. $new_mappings = array_filter( $new_mappings, 'is_int' ); if ( empty( $new_mappings ) ) { $new_mappings = array(); } // If we have no existing order map or // both the base and the new map have the same length and keys, we can simply use the new map. if ( empty( $base_map ) || ( count( $base_map ) === count( $new_mappings ) && empty( array_diff( array_keys( $base_map ), array_keys( $new_mappings ) ) ) ) ) { $new_order_map = $new_mappings; } else { // If we are dealing with ONLY offline PMs updates (for all that are registered) and their group is present, // normalize the new order map to keep behavior as intended (i.e., reorder only inside the offline PMs list). $offline_pms = $this->get_offline_payment_methods_gateways(); // Make it a list keyed by the payment gateway ID. $offline_pms = array_combine( array_map( fn( $gateway ) => $gateway->id, $offline_pms ), $offline_pms ); if ( isset( $base_map[ self::OFFLINE_METHODS_ORDERING_GROUP ] ) && count( $new_mappings ) === count( $offline_pms ) && empty( array_diff( array_keys( $new_mappings ), array_keys( $offline_pms ) ) ) ) { $new_mappings = Utils::order_map_change_min_order( $new_mappings, $base_map[ self::OFFLINE_METHODS_ORDERING_GROUP ] + 1 ); } $new_order_map = Utils::order_map_apply_mappings( $base_map, $new_mappings ); } return Utils::order_map_normalize( $new_order_map ); }