Automattic\WooCommerce\Internal\Admin\Suggestions\Incentives
Incentive::get_dismissals
Get the dismissals (contexts) for an incentive.
Метод класса: Incentive{}
Хуков нет.
Возвращает
Массив. The contexts in which the incentive has been dismissed.
Использование
$Incentive = new Incentive(); $Incentive->get_dismissals( $id ): array;
- $id(строка) (обязательный)
- The incentive ID.
Код Incentive::get_dismissals() Incentive::get dismissals WC 10.3.5
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
);
}