Automattic\WooCommerce\Internal\StockNotifications\Utilities
EligibilityService::is_notification_throttled
Check if notification is throttled.
Method of the class: EligibilityService{}
Hooks from the method
Returns
true|false.
Usage
// private - for code of main (parent) class only $result = $this->is_notification_throttled( $notification ): bool;
- $notification(Notification) (required)
- The notification object.
EligibilityService::is_notification_throttled() EligibilityService::is notification throttled code WC 10.3.6
private function is_notification_throttled( Notification $notification ): bool {
/**
* Filter: woocommerce_customer_stock_notification_throttle_threshold
*
* @since 10.2.0
*
* @param int $threshold Throttle time in seconds should pass from the last notification delivery time.
*/
$threshold = (int) apply_filters( 'woocommerce_customer_stock_notification_throttle_threshold', self::SPAM_THRESHOLD );
if ( $threshold <= 0 ) {
return false;
}
$last_notified = $notification->get_date_notified();
$is_throttled = $last_notified instanceof \WC_DateTime && $last_notified->getTimestamp() > ( time() - $threshold );
return $is_throttled;
}