Automattic\WooCommerce\Internal\Admin\Schedulers
OrdersScheduler::get_items()
Get the order/refund IDs and total count that need to be synced.
{} Это метод класса: OrdersScheduler{}
Хуков нет.
Возвращает
null
. Ничего.
Использование
$result = OrdersScheduler::get_items( $limit, $page, $days, $skip_existing );
- $limit(int)
- Number of records to retrieve.
По умолчанию: 10 - $page(int)
- Page number.
По умолчанию: 1 - $days(int|true|false)
- Number of days prior to current date to limit search results.
По умолчанию: false - $skip_existing(true|false)
- Skip already imported orders.
По умолчанию: false
Код OrdersScheduler::get_items() OrdersScheduler::get items WC 6.6.1
public static function get_items( $limit = 10, $page = 1, $days = false, $skip_existing = false ) { global $wpdb; $where_clause = ''; $offset = $page > 1 ? ( $page - 1 ) * $limit : 0; if ( is_int( $days ) ) { $days_ago = gmdate( 'Y-m-d 00:00:00', time() - ( DAY_IN_SECONDS * $days ) ); $where_clause .= " AND post_date_gmt >= '{$days_ago}'"; } if ( $skip_existing ) { $where_clause .= " AND NOT EXISTS ( SELECT 1 FROM {$wpdb->prefix}wc_order_stats WHERE {$wpdb->prefix}wc_order_stats.order_id = {$wpdb->posts}.ID )"; } $count = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_type IN ( 'shop_order', 'shop_order_refund' ) AND post_status NOT IN ( 'wc-auto-draft', 'auto-draft', 'trash' ) {$where_clause}" ); // phpcs:ignore unprepared SQL ok. $order_ids = absint( $count ) > 0 ? $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type IN ( 'shop_order', 'shop_order_refund' ) AND post_status NOT IN ( 'wc-auto-draft', 'auto-draft', 'trash' ) {$where_clause} ORDER BY post_date_gmt ASC LIMIT %d OFFSET %d", $limit, $offset ) ) : array(); // phpcs:ignore unprepared SQL ok. return (object) array( 'total' => absint( $count ), 'ids' => $order_ids, ); }