Plugin Directory

Changeset 3490342


Ignore:
Timestamp:
03/24/2026 08:17:59 PM (4 days ago)
Author:
routedev
Message:

add update for included_order_statuses and _routeapp_cancel_order_statuses

Location:
routeapp/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • routeapp/trunk/admin/class-routeapp-order-recover.php

    r3486829 r3490342  
    100100     */
    101101    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);
    110110    }
    111111
     
    143143    public function updateOrderPostMeta($orders) {
    144144        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')) {
    149146                //check if order exists on Route side
    150147                $getOrderResponse = Routeapp_API_Client::getInstance()->get_order($order->get_id());
     
    159156    /**
    160157     * 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.
    165161     * @return int The count of orders.
    166162     */
     
    168164        global $wpdb;
    169165
    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)
    193168                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'
    196170                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;
    216178    }
    217179
  • routeapp/trunk/public/js/routeapp-public-pbc.js

    r3486821 r3490342  
    6767         */
    6868        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
    8386                    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
    8790                triggerCheckoutUpdate();
    8891            }
     
    99102                },
    100103                success: function () {
    101                     if (isBlocksCheckoutAvailable()) {
    102                         triggerBlocksCheckoutCartUpdate();
    103                     } else if (RouteConfig.is_cart_page) {
     104                    if (RouteConfig.is_cart_page) {
    104105                        triggerCartUpdate();
    105106                    } else {
    106                         triggerCheckoutUpdate();
     107                        // Use blocks checkout update if available, otherwise fallback to traditional
     108                        if (isBlocksCheckoutAvailable()) {
     109                            triggerBlocksCheckoutCartUpdate();
     110                        } else {
     111                            triggerCheckoutUpdate();
     112                        }
    107113                    }
    108114
  • routeapp/trunk/readme.txt

    r3486829 r3490342  
    66Requires at least: 4.0
    77Tested up to: 6.7.1
    8 Stable tag: 2.3.2
     8Stable tag: 2.3.0
    99Requires PHP: 5.6
    1010License: GPLv2 or later
     
    106106
    107107== Changelog ==
    108 
    109 = 2.3.2 =
    110 * Fix order sync compatibility with HPOS and legacy storage
    111 
    112 = 2.3.1 =
    113 * Fix checkout order summary not updating when Route protection is toggled on blocks-based checkout
    114108
    115109= 2.3.0 =
  • routeapp/trunk/routeapp.php

    r3486829 r3490342  
    1010 * Plugin URI:        https://route.com/for-merchants/
    1111 * 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.2
     12 * Version:           2.3.0
    1313 * Author:            Route
    1414 * Author URI:        https://route.com/
     
    2626 * Currently plugin version.
    2727 */
    28 define( 'ROUTEAPP_VERSION', '2.3.2' );
     28define( 'ROUTEAPP_VERSION', '2.3.0' );
    2929
    3030/**
Note: See TracChangeset for help on using the changeset viewer.