Changeset 3486829
- Timestamp:
- 03/19/2026 09:12:33 PM (9 days ago)
- Location:
- routeapp/trunk
- Files:
-
- 3 edited
-
admin/class-routeapp-order-recover.php (modified) (4 diffs)
-
readme.txt (modified) (2 diffs)
-
routeapp.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
routeapp/trunk/admin/class-routeapp-order-recover.php
r3142452 r3486829 100 100 */ 101 101 private function getOrdersBatch($batchSize, $offset, $recoverTo, $recoverFrom) { 102 $args = [103 'limit' =>$batchSize,104 'offset' =>$offset,105 'date_created' => '>=' . $recoverFrom,106 'date_created' => '<=' . $recoverTo,107 ];108 109 return wc_get_orders( $args);102 $args = array( 103 'limit' => (int) $batchSize, 104 'offset' => (int) $offset, 105 'type' => 'shop_order', 106 'date_created' => $recoverFrom . '...' . $recoverTo, 107 ); 108 109 return wc_get_orders( $args ); 110 110 } 111 111 … … 143 143 public function updateOrderPostMeta($orders) { 144 144 foreach ($orders as $order) { 145 if (!get_post_meta( $order->get_id(), '_routeapp_order_id')) { 145 $has_route_meta = method_exists( $order, 'get_meta' ) 146 ? $order->get_meta( '_routeapp_order_id' ) 147 : get_post_meta( $order->get_id(), '_routeapp_order_id', true ); 148 if ( ! $has_route_meta ) { 146 149 //check if order exists on Route side 147 150 $getOrderResponse = Routeapp_API_Client::getInstance()->get_order($order->get_id()); … … 156 159 /** 157 160 * Get the count of orders based on the specified date range. 158 * 159 * @param string $from Starting date for the orders. 160 * @param string $to Ending date for the orders. 161 * Supports both High-performance order storage (HPOS) and WordPress posts storage (legacy). 162 * 163 * @param string $from Starting date for the orders (YYYY-MM-DD). 164 * @param string $to Ending date for the orders (YYYY-MM-DD). 161 165 * @return int The count of orders. 162 166 */ … … 164 168 global $wpdb; 165 169 166 $query = " 167 SELECT COUNT(1) 170 $from_date = $from . ' 00:00:00'; 171 $to_date = $to . ' 23:59:59'; 172 173 if ( $this->is_hpos_enabled() ) { 174 // High-performance order storage: query wc_orders table 175 $orders_table = $wpdb->prefix . 'wc_orders'; 176 $from_gmt = get_gmt_from_date( $from_date ); 177 $to_gmt = get_gmt_from_date( $to_date ); 178 179 $query = $wpdb->prepare( 180 "SELECT COUNT(1) 181 FROM {$orders_table} AS orders 182 WHERE orders.type = 'shop_order' 183 AND orders.status NOT IN ( 'wc-auto-draft', 'auto-draft', 'trash' ) 184 AND orders.date_created_gmt >= %s 185 AND orders.date_created_gmt <= %s", 186 $from_gmt, 187 $to_gmt 188 ); 189 } else { 190 // WordPress posts storage (legacy): query wp_posts 191 $query = $wpdb->prepare( 192 "SELECT COUNT(1) 168 193 FROM {$wpdb->posts} AS posts 169 WHERE posts.post_type = 'shop_order_placehold' 194 WHERE posts.post_type = 'shop_order' 195 AND posts.post_status NOT IN ( 'wc-auto-draft', 'auto-draft', 'trash' ) 170 196 AND posts.post_date >= %s 171 AND posts.post_date <= %s 172 "; 173 174 $prepared_query = $wpdb->prepare($query, $from, $to); 175 $order_count = $wpdb->get_var($prepared_query); 176 177 return $order_count; 197 AND posts.post_date <= %s", 198 $from_date, 199 $to_date 200 ); 201 } 202 203 return (int) $wpdb->get_var( $query ); 204 } 205 206 /** 207 * Check if High-performance order storage (HPOS) is enabled. 208 * 209 * @return bool True if HPOS is enabled, false otherwise. 210 */ 211 private function is_hpos_enabled() { 212 if ( ! class_exists( 'Automattic\WooCommerce\Utilities\OrderUtil' ) ) { 213 return false; 214 } 215 return \Automattic\WooCommerce\Utilities\OrderUtil::custom_orders_table_usage_is_enabled(); 178 216 } 179 217 -
routeapp/trunk/readme.txt
r3486821 r3486829 6 6 Requires at least: 4.0 7 7 Tested up to: 6.7.1 8 Stable tag: 2.3. 18 Stable tag: 2.3.2 9 9 Requires PHP: 5.6 10 10 License: GPLv2 or later … … 106 106 107 107 == Changelog == 108 109 = 2.3.2 = 110 * Fix order sync compatibility with HPOS and legacy storage 108 111 109 112 = 2.3.1 = -
routeapp/trunk/routeapp.php
r3486821 r3486829 10 10 * Plugin URI: https://route.com/for-merchants/ 11 11 * Description: Route allows shoppers to insure their orders with one-click during checkout, adding a layer of 3rd party trust while improving the customer shopping experience. 12 * Version: 2.3. 112 * Version: 2.3.2 13 13 * Author: Route 14 14 * Author URI: https://route.com/ … … 26 26 * Currently plugin version. 27 27 */ 28 define( 'ROUTEAPP_VERSION', '2.3. 1' );28 define( 'ROUTEAPP_VERSION', '2.3.2' ); 29 29 30 30 /**
Note: See TracChangeset
for help on using the changeset viewer.