Automattic\WooCommerce\Internal\Admin\Suggestions
PaymentsExtensionSuggestionIncentives::get_incentives
Get the incentives list for a specific payment extension suggestion.
Method of the class: PaymentsExtensionSuggestionIncentives{}
No Hooks.
Returns
Array. The incentives list.
Usage
$PaymentsExtensionSuggestionIncentives = new PaymentsExtensionSuggestionIncentives(); $PaymentsExtensionSuggestionIncentives->get_incentives( $suggestion_id, $country_code, $incentive_type, $skip_visibility_check ): array;
- $suggestion_id(string) (required)
- The suggestion ID.
- $country_code(string) (required)
- The business location country code to get incentives for.
- $incentive_type(string)
- The type of incentive to check for. If not provided, all incentives for the suggestion will be returned.
Default: '' - $skip_visibility_check(true|false)
- Whether to skip the visibility check for the incentives.
Default: false
PaymentsExtensionSuggestionIncentives::get_incentives() PaymentsExtensionSuggestionIncentives::get incentives code WC 10.3.3
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 );
}