Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableDataStore::get_unpaid_orders()publicWC 1.0

Get unpaid orders last updated before the specified date.

{} It's a method of the class: OrdersTableDataStore{}

No Hooks.

Return

Array.

Usage

$OrdersTableDataStore = new OrdersTableDataStore();
$OrdersTableDataStore->get_unpaid_orders( $date );
$date(int) (required)
Timestamp.

Code of OrdersTableDataStore::get_unpaid_orders() WC 7.1.0

public function get_unpaid_orders( $date ) {
	global $wpdb;

	$orders_table    = self::get_orders_table_name();
	$order_types_sql = "('" . implode( "','", wc_get_order_types() ) . "')";

	// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
	return $wpdb->get_col(
		$wpdb->prepare(
			"SELECT id FROM {$orders_table} WHERE
			{$orders_table}.type IN {$order_types_sql}
			AND {$orders_table}.status = %s
			AND {$orders_table}.date_updated_gmt < %s",
			'wc-pending',
			gmdate( 'Y-m-d H:i:s', absint( $date ) )
		)
	);
	// phpcs:enable
}