WC_Tracker::get_order_dates()private staticWC 1.0

Get last order date.

Метод класса: WC_Tracker{}

Хуков нет.

Возвращает

Строку.

Использование

$result = WC_Tracker::get_order_dates();

Код WC_Tracker::get_order_dates() WC 8.9.3

private static function get_order_dates() {
	global $wpdb;

	$orders_table = OrdersTableDataStore::get_orders_table_name();
	if ( OrderUtil::custom_orders_table_usage_is_enabled() ) {
		// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
		$min_max = $wpdb->get_row(
			"
			SELECT
				MIN( date_created_gmt ) as 'first', MAX( date_created_gmt ) as 'last'
			FROM $orders_table
			WHERE status = 'wc-completed';
			",
			ARRAY_A
		);
		// phpcs:enable
	} else {
		$min_max = $wpdb->get_row(
			"
				SELECT
					MIN( post_date_gmt ) as 'first', MAX( post_date_gmt ) as 'last'
				FROM {$wpdb->prefix}posts
				WHERE post_type = 'shop_order'
				AND post_status = 'wc-completed'
			",
			ARRAY_A
		);
	}

	if ( is_null( $min_max ) ) {
		$min_max = array(
			'first' => '-',
			'last'  => '-',
		);
	}

	if ( OrderUtil::custom_orders_table_usage_is_enabled() ) {
		// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
		$processing_min_max = $wpdb->get_row(
			"
			SELECT
				MIN( date_created_gmt ) as 'processing_first', MAX( date_created_gmt ) as 'processing_last'
			FROM $orders_table
			WHERE status = 'wc-processing';
			",
			ARRAY_A
		);
		// phpcs:enable
	} else {
		$processing_min_max = $wpdb->get_row(
			"
			SELECT
				MIN( post_date_gmt ) as 'processing_first', MAX( post_date_gmt ) as 'processing_last'
			FROM {$wpdb->prefix}posts
			WHERE post_type = 'shop_order'
			AND post_status = 'wc-processing'
		",
			ARRAY_A
		);
	}

	if ( is_null( $processing_min_max ) ) {
		$processing_min_max = array(
			'processing_first' => '-',
			'processing_last'  => '-',
		);
	}

	return array_merge( $min_max, $processing_min_max );
}