Automattic\WooCommerce\Internal\Admin\Suggestions\Incentives
Incentive::get_dismissals
Get the dismissals (contexts) for an incentive.
Method of the class: Incentive{}
No Hooks.
Returns
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() Incentive::get dismissals code WC 10.4.3
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_values(
array_filter(
$dismissed_incentives,
fn( $dismissed_incentive ) => $id === $dismissed_incentive['id']
)
);
return array_map(
fn( $dismissed_incentive ) => array(
'timestamp' => $dismissed_incentive['timestamp'],
'context' => $dismissed_incentive['context'],
),
$dismissals
);
}