Automattic\WooCommerce\Internal\Admin\Suggestions\Incentives

Incentive::get_dismissals()publicWC 1.0

Get the dismissals (contexts) for an incentive.

Method of the class: Incentive{}

No Hooks.

Return

Array. The contexts in which the incentive has been dismissed.

Usage

$Incentive = new Incentive();
$Incentive->get_dismissals( $id ): array;
$id(string) (required)
The incentive ID.

Incentive::get_dismissals() code WC 9.6.1

public function get_dismissals( string $id ): array {
	$all_dismissed_incentives = $this->get_all_dismissed_incentives();

	// If there are no dismissed incentives for the suggestion, return early.
	$dismissed_incentives = $all_dismissed_incentives[ $this->suggestion_id ] ?? array();
	if ( empty( $dismissed_incentives ) ) {
		return array();
	}

	$dismissals = array_filter(
		$dismissed_incentives,
		fn( $dismissed_incentive ) => $id === $dismissed_incentive['id']
	);

	return array_column( $dismissals, 'context' );
}