Automattic\WooCommerce\Internal\Admin\Schedulers
OrdersScheduler::get_orders_since_from_posts_table
Get orders from posts table updated since the specified cursor position.
Uses the same compound cursor logic as get_orders_since_from_orders_table() but queries the posts table instead of the HPOS orders table.
Method of the class: OrdersScheduler{}
No Hooks.
Returns
Array. Array of objects with 'id' and 'date_updated_gmt' properties.
Usage
$result = OrdersScheduler::get_orders_since_from_posts_table( $cursor_date, $cursor_id, $limit );
- $cursor_date(string) (required)
- Cursor date in
'Y-m-d H:i:s'format. - $cursor_id(int) (required)
- Cursor order ID.
- $limit(int) (required)
- Number of orders to retrieve.
OrdersScheduler::get_orders_since_from_posts_table() OrdersScheduler::get orders since from posts table code WC 10.5.0
private static function get_orders_since_from_posts_table( $cursor_date, $cursor_id, $limit ) {
global $wpdb;
return $wpdb->get_results(
$wpdb->prepare(
"SELECT ID as id, post_modified_gmt as date_updated_gmt
FROM {$wpdb->posts}
WHERE post_type IN ('shop_order', 'shop_order_refund')
AND post_status NOT IN ('wc-auto-draft', 'auto-draft', 'trash')
AND (
post_modified_gmt > %s
OR (post_modified_gmt = %s AND ID > %d)
)
ORDER BY post_modified_gmt ASC, ID ASC
LIMIT %d",
$cursor_date,
$cursor_date,
$cursor_id,
$limit
)
);
}