Automattic\WooCommerce\Internal\StockNotifications

DataRetentionController::do_wc_customer_stock_notifications_dailypublicWC 1.0

Deletes overdue notifications based on the configured time threshold. It retrieves notifications that are pending and past the threshold, then deletes them.

Method of the class: DataRetentionController{}

No Hooks.

Returns

null. Nothing (null).

Usage

$DataRetentionController = new DataRetentionController();
$DataRetentionController->do_wc_customer_stock_notifications_daily();

DataRetentionController::do_wc_customer_stock_notifications_daily() code WC 10.3.6

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