Automattic\WooCommerce\Internal\StockNotifications
DataRetentionController::do_wc_customer_stock_notifications_daily
Deletes overdue notifications based on the configured time threshold. It retrieves notifications that are pending and past the threshold, then deletes them.
Метод класса: DataRetentionController{}
Хуков нет.
Возвращает
void. Ничего (null).
Использование
$DataRetentionController = new DataRetentionController(); $DataRetentionController->do_wc_customer_stock_notifications_daily();
Код DataRetentionController::do_wc_customer_stock_notifications_daily() DataRetentionController::do wc customer stock notifications daily WC 11.2.2
public function do_wc_customer_stock_notifications_daily() {
$time_threshold = Config::get_unverified_deletion_days_threshold();
if ( 0 === $time_threshold ) {
return;
}
$overdue_threshold = time() - $time_threshold * DAY_IN_SECONDS;
$overdue_notifications = NotificationQuery::get_notifications(
array(
'status' => NotificationStatus::PENDING,
'end_date' => gmdate( 'Y-m-d H:i:s', $overdue_threshold ),
)
);
foreach ( $overdue_notifications as $notification_id ) {
$notification = Factory::get_notification( $notification_id );
if ( $notification instanceof Notification ) {
$notification->delete();
}
}
}