Plugin Directory

Changeset 3452273


Ignore:
Timestamp:
02/02/2026 05:08:18 PM (3 weeks ago)
Author:
routedev
Message:

Fix local pickup flag resolution and prevent false positives

Location:
routeapp/trunk
Files:
3 edited

Legend:

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

    r3448191 r3452273  
    952952
    953953        //MSS-6533: Add local pickup flag and excluded shipping methods meta data to the order
    954         $updated |= $this->updateRouteOrderMetaData( $order, $is_hpos, '_routeapp_order_local_pickup',
    955             !$this->routeapp_is_shipping_method_allowed(false, $order) ? 1 : 0);
     954        $updated |= $this->updateRouteOrderMetaData( $order, $is_hpos,'_routeapp_order_local_pickup', $this->routeapp_resolve_local_pickup_flag( $order ) );
    956955        $updated |= $this->updateRouteOrderMetaData( $order, $is_hpos, '_routeapp_excluded_shipping_methods', $this->routeapp_get_excluded_shipping_methods());
    957956
     
    17761775    }
    17771776
     1777    //MSS-6533
     1778    /**
     1779     * Resolve the local pickup flag in a FAIL-SAFE way.
     1780     *
     1781     * Priority:
     1782     * 1. Order shipping items
     1783     * 3. Checkout session (fallback only)
     1784     *
     1785     * @param WC_Order|null $order
     1786     *
     1787     * @return int 1 = local pickup, 0 = not local pickup
     1788     */
     1789    public function routeapp_resolve_local_pickup_flag( WC_Order $order = null): int {
     1790        $excluded_methods = $this->routeapp_get_excluded_shipping_methods();
     1791        if ( empty( $excluded_methods ) || ! is_array( $excluded_methods ) ) {
     1792            return 0;
     1793        }
     1794
     1795        // Order-based (most reliable).
     1796        if ( $order instanceof WC_Order ) {
     1797            $shipping_items = $order->get_shipping_methods();
     1798            if ( ! empty( $shipping_items ) ) {
     1799                foreach ( $shipping_items as $shipping_item ) {
     1800                    if ( ! $shipping_item instanceof WC_Order_Item_Shipping ) {
     1801                        continue;
     1802                    }
     1803                    $method_id = $shipping_item->get_method_id();
     1804                    if ( empty( $method_id ) ) {
     1805                        continue;
     1806                    }
     1807                    $method_id = explode( ':', $method_id )[0];
     1808                    if ( in_array( $method_id, $excluded_methods, true ) ) {
     1809                        return 1;
     1810                    }
     1811                }
     1812                return 0;
     1813            }
     1814        }
     1815
     1816        // Session fallback (checkout only).
     1817        if ( ! function_exists( 'WC' ) || ! WC()->session ) {
     1818            return 0;
     1819        }
     1820        $chosen = WC()->session->get( 'chosen_shipping_methods' );
     1821        $packages = WC()->session->get( 'shipping_for_package_0' );
     1822        if ( empty( $chosen[0] ) || empty( $packages['rates'] ) ) {
     1823            return 0;
     1824        }
     1825        $chosen_id = $chosen[0];
     1826        if ( ! isset( $packages['rates'][ $chosen_id ] ) ) {
     1827            return 0;
     1828        }
     1829        $method_id = explode( ':', $packages['rates'][ $chosen_id ]->id )[0];
     1830        if ( in_array( $method_id, $excluded_methods, true ) ) {
     1831            return 1;
     1832        }
     1833
     1834        return 0;
     1835    }
     1836
     1837
    17781838}
    17791839
  • routeapp/trunk/readme.txt

    r3448191 r3452273  
    66Requires at least: 4.0
    77Tested up to: 6.7.1
    8 Stable tag: 2.2.35
     8Stable tag: 2.2.36
    99Requires PHP: 5.6
    1010License: GPLv2 or later
     
    106106
    107107== Changelog ==
     108
     109= 2.2.36 =
     110* Fix local pickup flag resolution and prevent false positives
    108111
    109112= 2.2.35 =
  • routeapp/trunk/routeapp.php

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