Plugin Directory

Changeset 3339895


Ignore:
Timestamp:
08/05/2025 09:38:34 PM (8 months ago)
Author:
routedev
Message:

add metadata to draft orders

Location:
routeapp/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • routeapp/trunk/public/class-routeapp-public.php

    r3229864 r3339895  
    154154
    155155        add_action('woocommerce_order_details_after_order_table', array($this, 'order_updates_route_tracking'), 1, 1);
     156
     157        add_action('woocommerce_blocks_checkout_update_order_meta', array($this, 'routeapp_save_order_status_to_order'), 10, 1);
     158        add_action('woocommerce_store_api_checkout_update_order_meta', array($this, 'routeapp_save_order_status_to_order'), 10, 1);
    156159    }
    157160
     
    767770        return true;
    768771    }
     772
     773
     774    /**
     775     * Updates Route-related metadata to the order after it is placed in draft status.
     776     *
     777     * This method is triggered when an order is created in draft status and is responsible for
     778     * adding meta fields with the list Route sync status.
     779     * This prevents incorrect synchronization of draft orders.
     780     *
     781     * @param int $order_id The ID of the WooCommerce order.
     782     */
     783    public function routeapp_save_order_status_to_order( $order_id ) {
     784        if ( ! $order_id || ! WC()->session ) {
     785            return;
     786        }
     787
     788        try {
     789            $order = wc_get_order( $order_id );
     790
     791            if ( ! $order ) {
     792                throw new Exception( "Order with ID {$order_id} could not be retrieved." );
     793            }
     794
     795            $this->updateRouteIncludedOrderStatusMetaFields( $order );
     796
     797        } catch ( Exception $e ) {
     798            error_log( "An error occurred while updating Route order status meta fields for order ID {$order_id}: " . $e->getMessage() );
     799        }
     800    }
     801
    769802
    770803    /**
  • routeapp/trunk/readme.txt

    r3327817 r3339895  
    66Requires at least: 4.0
    77Tested up to: 6.7.1
    8 Stable tag: 2.2.27
     8Stable tag: 2.2.28
    99Requires PHP: 5.6
    1010License: GPLv2 or later
     
    106106
    107107== Changelog ==
     108
     109= 2.2.28 =
     110* Add Route metaData to draft orders
    108111
    109112= 2.2.27 =
  • routeapp/trunk/routeapp.php

    r3327817 r3339895  
    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.2.27
     12 * Version:           2.2.28
    1313 * Author:            Route
    1414 * Author URI:        https://route.com/
     
    2626 * Currently plugin version.
    2727 */
    28 define( 'ROUTEAPP_VERSION', '2.2.27' );
     28define( 'ROUTEAPP_VERSION', '2.2.28' );
    2929
    3030/**
Note: See TracChangeset for help on using the changeset viewer.