Automattic\WooCommerce\Internal\Admin\Schedulers

OrdersScheduler::initialize_last_processed_dateprivate staticWC 1.0

Initialize the last processed date option if not set.

Method of the class: OrdersScheduler{}

No Hooks.

Returns

null. Nothing (null).

Usage

$result = OrdersScheduler::initialize_last_processed_date();

OrdersScheduler::initialize_last_processed_date() code WC 10.4.3

private static function initialize_last_processed_date() {
	if ( false !== get_option( self::LAST_PROCESSED_ORDER_DATE_OPTION, false ) ) {
		return; // Already initialized.
	}

	/**
	 * Add buffer to ensure orders created or updated during plugin activation, upgrade, or prior to import are accounted for.
	 * Buffer in seconds. 10 minutes.
	 */
	$buffer_seconds = 10 * MINUTE_IN_SECONDS;
	$start_date     = gmdate( 'Y-m-d H:i:s', time() - $buffer_seconds );

	update_option( self::LAST_PROCESSED_ORDER_DATE_OPTION, $start_date, false );
	update_option( self::LAST_PROCESSED_ORDER_ID_OPTION, 0, false );
}