Automattic\WooCommerce\Internal\Admin\Suggestions
PaymentExtensionSuggestions::get_extension_incentive()
Get the incentive details for a given extension and country, if any.
Метод класса: PaymentExtensionSuggestions{}
Хуков нет.
Возвращает
Массив|null
. The incentive details for the given extension and country. Null if not found.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_extension_incentive( $extension_id, $country_code, $context ): ?array;
- $extension_id(строка) (обязательный)
- The extension ID.
- $country_code(строка) (обязательный)
- The two-letter country code.
- $context(строка)
- The context ID of where the extension incentive is being used.
По умолчанию: ''
Код PaymentExtensionSuggestions::get_extension_incentive() PaymentExtensionSuggestions::get extension incentive WC 9.6.1
private function get_extension_incentive( string $extension_id, string $country_code, string $context = '' ): ?array { // Try to map the context to an incentive type. $incentive_type = ''; if ( isset( $this->context_to_incentive_type_map[ $context ] ) ) { $incentive_type = $this->context_to_incentive_type_map[ $context ]; } $incentives = $this->suggestion_incentives->get_incentives( $extension_id, $country_code, $incentive_type ); if ( empty( $incentives ) ) { return null; } // Use the first incentive, in case there are multiple. $incentive = reset( $incentives ); // Sanitize the incentive details. $incentive = $this->sanitize_extension_incentive( $incentive ); // Enhance the incentive details. $incentive['_suggestion_id'] = $extension_id; // Add the dismissals list. $incentive['_dismissals'] = array_unique( array_values( $this->suggestion_incentives->get_incentive_dismissals( $incentive['id'], $extension_id ) ) ); return $incentive; }