Plugin Directory

Changeset 3306198


Ignore:
Timestamp:
06/04/2025 07:32:17 AM (10 months ago)
Author:
bobgroup
Message:

Deploy version 3.0.90

Location:
uafrica-shipping/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uafrica-shipping/trunk/app/class-woocommerce.php

    r3283903 r3306198  
    2424        }
    2525
     26        // Skip if it's a subscription or a renewal
     27        if (self::is_subscription_order($order)) {
     28            return;
     29        }
     30
    2631        // To prevent infinite loops, we need to remove the action and add it again after saving the order meta
    2732        remove_action('woocommerce_update_order', [ '\uAfrica_Shipping\app\WooCommerce', 'save_order_meta' ], 10);
     
    4146        // Save the order meta
    4247        $order->save();
     48
    4349        // We need to add the action again after saving the order meta
    4450        add_action( 'woocommerce_update_order', [ '\uAfrica_Shipping\app\WooCommerce', 'save_order_meta' ], 10, 2 );
     
    6167        $order = is_a( $order, 'WC_Order' ) ? $order : wc_get_order( $order_id );
    6268
    63         // Total grams
     69
     70        // Skip if it's a subscription or a renewal
     71        if (self::is_subscription_order($order)) {
     72            return;
     73        }
     74
     75        // Total grams
    6476        self::include_total_grams_in_order($order_id, $order);
    6577
     
    8496
    8597        $weight = 0;
    86         $cart   = WC()->cart;
     98        $cart = null;
     99        if ( WC()->cart ) {
     100            $cart = WC()->cart;
     101        }
     102
    87103        if ( $cart !== null ) {
    88104            // Grab total weight from cart.
     
    677693    }
    678694
    679 //    private static function bobgo_log($message)
    680 //    {
    681 //        if ( function_exists( 'wc_get_logger' ) ) {
    682 //            $logger  = wc_get_logger();
    683 //            $logger->debug( $message );
    684 //        }
    685 //    }
     695    private static function bobgo_log($message)
     696    {
     697        if ( function_exists( 'wc_get_logger' ) ) {
     698            $logger  = wc_get_logger();
     699            $logger->debug( $message );
     700        }
     701    }
     702
     703    /**
     704     * Checks whether an order is a subscription order.
     705     *
     706     * @param WC_Customer|WC_Order $order The order
     707     * @param int $order_id The order ID.
     708     *
     709     * @return bool
     710     *
     711     **/
     712    private static function is_subscription_order($order)
     713    {
     714        if ( empty( $order ) || $order === false ) {
     715            return false;
     716        }
     717
     718        // Return true if it's a subscription or a renewal
     719        if ( method_exists( $order, 'get_type' ) && $order->get_type() === 'shop_subscription' ) {
     720            return true;
     721        }
     722        if ( $order->get_meta( '_subscription_renewal', true ) ) {
     723            return true;
     724        }
     725
     726        return false;
     727    }
    686728}
  • uafrica-shipping/trunk/readme.txt

    r3305500 r3306198  
    66Tested up to: 6.7
    77Requires PHP: 7.0.0
    8 Stable tag: 3.0.88
     8Stable tag: 3.0.90
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    7878== Changelog ==
    7979
     80= 3.0.90 =
     81* Fix handling order meta updates for WooCommerce Subscriptions
     82
    8083= 3.0.88 =
    8184* Display the estimated delivery date range on the tracking page
  • uafrica-shipping/trunk/uafrica-shipping.php

    r3305500 r3306198  
    1313 * Requires at least: 5.0
    1414 * Requires PHP:      7.0
    15  * Version:           3.0.88
     15 * Version:           3.0.90
    1616 * License:           GPLv2 or later
    1717 *
     
    2525 */
    2626
    27 define( 'UAFRICA_SHIPPING_VERSION', '3.0.88' );
     27define( 'UAFRICA_SHIPPING_VERSION', '3.0.90' );
    2828// Endpoints for tracking orders.
    2929define( 'UAFRICA_SHIPPING_API_TRACKING_V3', 'https://api.bobgo.co.za/tracking?channel=DOMAIN&tracking_reference=NUMBER' );
Note: See TracChangeset for help on using the changeset viewer.