Incorrect date handling when exporting orders (Fix missing orders)
-
Hey team,
We’ve been facing this issue for quite a while and have to make our own patch with each update.
Related file:
woocommerce-shipstation-integration/includes/api-requests/class-wc-shipstation-api-export.php?
The issue:
The date calculations aren’t working on our site, and sure it’s also the reason for other “orders missing” type of tickets. The query to fetch all orders between the start and end date returns no orders, even if there are any.
I haven’t looked into which exact dates the the query uses as we needed a quick fix.The fix:
We override the plugins code in the file above. The code I’ve changed is to export all modifed orders since 2 days ago. This means all new/updated orders will be included. This way we don’t need an “end” date, incase that’s where the original code goes wrong.$date = new DateTime(); // HOT FIX $date->modify("-2 day"); // HOT FIX $orders_to_export = wc_get_orders( array( 'date_modified' => '>=' . $date->format("Y-m-d"), // HOT FIX //'date_modified' => strtotime( $start_date ) . '...' . strtotime( $end_date ), // Incorrect 'type' => 'shop_order', 'status' => WC_ShipStation_Integration::$export_statuses, 'return' => 'ids', 'orderby' => 'date_modified', 'order' => 'DESC', 'paged' => $page, 'limit' => WC_SHIPSTATION_EXPORT_LIMIT, ) ); $total_orders_to_export = wc_get_orders( array( 'type' => 'shop_order', 'date_modified' => '>=' . $date->format("Y-m-d"), // HOT FIX //'date_modified' => strtotime( $start_date ) . '...' . strtotime( $end_date ), // Incorrect 'status' => WC_ShipStation_Integration::$export_statuses, 'paginate' => true, 'return' => 'ids', ) );
Please look into this, thank you very much ??
- The topic ‘Incorrect date handling when exporting orders (Fix missing orders)’ is closed to new replies.