Automattic\WooCommerce\Internal\Admin\Suggestions
PaymentsExtensionSuggestionIncentives::get_incentives
Get the incentives list for a specific payment extension suggestion.
Метод класса: PaymentsExtensionSuggestionIncentives{}
Хуков нет.
Возвращает
array. The incentives list.
Использование
$PaymentsExtensionSuggestionIncentives = new PaymentsExtensionSuggestionIncentives(); $PaymentsExtensionSuggestionIncentives->get_incentives( $suggestion_id, $country_code, $incentive_type, $skip_visibility_check ): array;
- $suggestion_id(строка) (обязательный)
- The suggestion ID.
- $country_code(строка) (обязательный)
- The business location country code to get incentives for.
- $incentive_type(строка)
- The type of incentive to check for. If not provided, all incentives for the suggestion will be returned.
По умолчанию:'' - $skip_visibility_check(true|false)
- Whether to skip the visibility check for the incentives.
По умолчанию:false
Код PaymentsExtensionSuggestionIncentives::get_incentives() PaymentsExtensionSuggestionIncentives::get incentives WC 11.3.0
public function get_incentives( string $suggestion_id, string $country_code, string $incentive_type = '', bool $skip_visibility_check = false ): array {
$provider = $this->get_incentive_instance( $suggestion_id );
if ( null === $provider ) {
return array();
}
$incentives = $provider->get_all( $country_code, $incentive_type );
if ( ! $skip_visibility_check ) {
$incentives = array_filter(
$incentives,
fn( $incentive ) => $provider->is_visible( $incentive['id'], $country_code )
);
}
return array_values( $incentives );
}