Automattic\WooCommerce\Internal\Admin\Settings
PaymentProviders::enhance_payment_gateway_details()
Enhance the payment gateway details with additional information from other sources.
Метод класса: PaymentProviders{}
Хуков нет.
Возвращает
Массив
. The enhanced gateway details.
Использование
// private - только в коде основоного (родительского) класса $result = $this->enhance_payment_gateway_details( $gateway_details, $payment_gateway, $country_code ): array;
- $gateway_details(массив) (обязательный)
- The gateway details to enhance.
- $payment_gateway(WC_Payment_Gateway) (обязательный)
- The payment gateway object.
- $country_code(строка) (обязательный)
- The country code for which the details are being enhanced. This should be a ISO 3166-1 alpha-2 country code.
Код PaymentProviders::enhance_payment_gateway_details() PaymentProviders::enhance payment gateway details WC 9.6.1
private function enhance_payment_gateway_details( array $gateway_details, WC_Payment_Gateway $payment_gateway, string $country_code ): array { // We discriminate between offline payment methods and gateways. $gateway_details['_type'] = $this->is_offline_payment_method( $payment_gateway->id ) ? self::TYPE_OFFLINE_PM : self::TYPE_GATEWAY; $plugin_slug = $gateway_details['plugin']['slug']; // The payment gateway plugin might use a non-standard directory name. // Try to normalize it to the common slug to avoid false negatives when matching. $normalized_plugin_slug = Utils::normalize_plugin_slug( $plugin_slug ); // If we have a matching suggestion, hoist details from there. // The suggestions only know about the normalized (aka official) plugin slug. $suggestion = $this->get_extension_suggestion_by_plugin_slug( $normalized_plugin_slug, $country_code ); if ( ! is_null( $suggestion ) ) { // Enhance the suggestion details. $suggestion = $this->enhance_extension_suggestion( $suggestion ); // The title, description, icon, and image from the suggestion take precedence over the ones from the gateway. // This is temporary until we update the partner extensions. // Do not override the title for certain suggestions because their title is more descriptive. if ( ! in_array( $suggestion['id'], array( ExtensionSuggestions::PAYPAL_FULL_STACK, ExtensionSuggestions::PAYPAL_WALLET, ), true ) ) { $gateway_details['title'] = $suggestion['title']; } $gateway_details['description'] = $suggestion['description']; $gateway_details['icon'] = $suggestion['icon']; $gateway_details['image'] = $suggestion['image']; if ( empty( $gateway_details['links'] ) ) { $gateway_details['links'] = $suggestion['links']; } if ( empty( $gateway_details['tags'] ) ) { $gateway_details['tags'] = $suggestion['tags']; } if ( empty( $gateway_details['plugin'] ) ) { $gateway_details['plugin'] = $suggestion['plugin']; } if ( empty( $gateway_details['_incentive'] ) && ! empty( $suggestion['_incentive'] ) ) { $gateway_details['_incentive'] = $suggestion['_incentive']; } // Attach the suggestion ID to the gateway details so we can reference it with precision. $gateway_details['_suggestion_id'] = $suggestion['id']; } // Get the gateway's corresponding plugin details. $plugin_data = PluginsHelper::get_plugin_data( $plugin_slug ); if ( ! empty( $plugin_data ) ) { // If there are no links, try to get them from the plugin data. if ( empty( $gateway_details['links'] ) ) { if ( is_array( $plugin_data ) && ! empty( $plugin_data['PluginURI'] ) ) { $gateway_details['links'] = array( array( '_type' => ExtensionSuggestions::LINK_TYPE_ABOUT, 'url' => esc_url( $plugin_data['PluginURI'] ), ), ); } elseif ( ! empty( $gateway_details['plugin']['_type'] ) && ExtensionSuggestions::PLUGIN_TYPE_WPORG === $gateway_details['plugin']['_type'] ) { // Fallback to constructing the WPORG plugin URI from the normalized plugin slug. $gateway_details['links'] = array( array( '_type' => ExtensionSuggestions::LINK_TYPE_ABOUT, 'url' => 'https://wordpress.org/plugins/' . $normalized_plugin_slug, ), ); } } } return $gateway_details; }