Automattic\WooCommerce\Internal\StockNotifications

DataRetentionController::do_wc_customer_stock_notifications_daily │ public │ WC 1.0

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() 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();
		}
	}
}