Automattic\WooCommerce\Internal\Admin\Suggestions\Incentives

Incentive::get_all()publicWC 1.0

Get the details of all the incentives.

The incentives are filtered based on the country code, incentive type, if provided, and their visibility.

Method of the class: Incentive{}

No Hooks.

Return

Array. The incentives list with details for each incentive.

Usage

$Incentive = new Incentive();
$Incentive->get_all( $country_code, $incentive_type ): array;
$country_code(string) (required)
The business location country code to get incentives for.
$incentive_type(string)
The type of incentive to check for.
Default: ''

Incentive::get_all() code WC 9.6.0

public function get_all( string $country_code, string $incentive_type = '' ): array {
	$incentives = array_filter(
		$this->get_incentives( $country_code ),
		fn( $incentive ) => $this->validate_incentive( $incentive )
	);

	if ( ! empty( $incentive_type ) ) {
		$incentives = array_filter(
			$incentives,
			function ( $incentive ) use ( $incentive_type ) {
				return $incentive['type'] === $incentive_type;
			}
		);
	}

	return array_values( $incentives );
}