Changeset 3490342
- Timestamp:
- 03/24/2026 08:17:59 PM (4 days ago)
- Location:
- routeapp/trunk
- Files:
-
- 4 edited
-
admin/class-routeapp-order-recover.php (modified) (4 diffs)
-
public/js/routeapp-public-pbc.js (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
routeapp.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
routeapp/trunk/admin/class-routeapp-order-recover.php
r3486829 r3490342 100 100 */ 101 101 private function getOrdersBatch($batchSize, $offset, $recoverTo, $recoverFrom) { 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);102 $args = [ 103 'limit' => $batchSize, 104 'offset' => $offset, 105 'date_created' => '>=' . $recoverFrom, 106 'date_created' => '<=' . $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 $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 ) { 145 if (!get_post_meta( $order->get_id(), '_routeapp_order_id')) { 149 146 //check if order exists on Route side 150 147 $getOrderResponse = Routeapp_API_Client::getInstance()->get_order($order->get_id()); … … 159 156 /** 160 157 * Get the count of orders based on the specified date range. 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). 158 * 159 * @param string $from Starting date for the orders. 160 * @param string $to Ending date for the orders. 165 161 * @return int The count of orders. 166 162 */ … … 168 164 global $wpdb; 169 165 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) 166 $query = " 167 SELECT COUNT(1) 193 168 FROM {$wpdb->posts} AS posts 194 WHERE posts.post_type = 'shop_order' 195 AND posts.post_status NOT IN ( 'wc-auto-draft', 'auto-draft', 'trash' ) 169 WHERE posts.post_type = 'shop_order_placehold' 196 170 AND posts.post_date >= %s 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(); 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; 216 178 } 217 179 -
routeapp/trunk/public/js/routeapp-public-pbc.js
r3486821 r3490342 67 67 */ 68 68 function triggerBlocksCheckoutCartUpdate() { 69 if (!isBlocksCheckoutAvailable()) { 70 triggerCheckoutUpdate(); 71 return; 72 } 73 74 try { 75 wc.blocksCheckout.extensionCartUpdate({ 76 namespace: 'route-widget-integration', 77 data: { 78 checkbox: RouteConfig.checkbox === Route.Coverage.ActiveByDefault 79 } 80 }).catch(function(error) { 81 console.error('Route widget: Cart update failed:', error); 82 }).finally(function() { 69 if (isBlocksCheckoutAvailable()) { 70 try { 71 wc.blocksCheckout.extensionCartUpdate({ 72 namespace: 'route-widget-integration', 73 data: { 74 checkbox: RouteConfig.checkbox === Route.Coverage.ActiveByDefault 75 } 76 }).then(function() { 77 // Cart update successful - the frontend will automatically refresh 78 }).catch(function(error) { 79 console.error('Route widget: Cart update failed:', error); 80 // Fallback to traditional checkout update 81 triggerCheckoutUpdate(); 82 }); 83 } catch (error) { 84 console.error('Route widget: Error triggering blocks checkout update:', error); 85 // Fallback to traditional checkout update 83 86 triggerCheckoutUpdate(); 84 } );85 } catch (error){86 console.error('Route widget: Error triggering blocks checkout update:', error);87 } 88 } else { 89 // Fallback to traditional checkout update if blocks checkout is not available 87 90 triggerCheckoutUpdate(); 88 91 } … … 99 102 }, 100 103 success: function () { 101 if (isBlocksCheckoutAvailable()) { 102 triggerBlocksCheckoutCartUpdate(); 103 } else if (RouteConfig.is_cart_page) { 104 if (RouteConfig.is_cart_page) { 104 105 triggerCartUpdate(); 105 106 } else { 106 triggerCheckoutUpdate(); 107 // Use blocks checkout update if available, otherwise fallback to traditional 108 if (isBlocksCheckoutAvailable()) { 109 triggerBlocksCheckoutCartUpdate(); 110 } else { 111 triggerCheckoutUpdate(); 112 } 107 113 } 108 114 -
routeapp/trunk/readme.txt
r3486829 r3490342 6 6 Requires at least: 4.0 7 7 Tested up to: 6.7.1 8 Stable tag: 2.3. 28 Stable tag: 2.3.0 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 storage111 112 = 2.3.1 =113 * Fix checkout order summary not updating when Route protection is toggled on blocks-based checkout114 108 115 109 = 2.3.0 = -
routeapp/trunk/routeapp.php
r3486829 r3490342 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. 212 * Version: 2.3.0 13 13 * Author: Route 14 14 * Author URI: https://route.com/ … … 26 26 * Currently plugin version. 27 27 */ 28 define( 'ROUTEAPP_VERSION', '2.3. 2' );28 define( 'ROUTEAPP_VERSION', '2.3.0' ); 29 29 30 30 /**
Note: See TracChangeset
for help on using the changeset viewer.