Changeset 3306198
- Timestamp:
- 06/04/2025 07:32:17 AM (10 months ago)
- Location:
- uafrica-shipping/trunk
- Files:
-
- 3 edited
-
app/class-woocommerce.php (modified) (5 diffs)
-
readme.txt (modified) (2 diffs)
-
uafrica-shipping.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uafrica-shipping/trunk/app/class-woocommerce.php
r3283903 r3306198 24 24 } 25 25 26 // Skip if it's a subscription or a renewal 27 if (self::is_subscription_order($order)) { 28 return; 29 } 30 26 31 // To prevent infinite loops, we need to remove the action and add it again after saving the order meta 27 32 remove_action('woocommerce_update_order', [ '\uAfrica_Shipping\app\WooCommerce', 'save_order_meta' ], 10); … … 41 46 // Save the order meta 42 47 $order->save(); 48 43 49 // We need to add the action again after saving the order meta 44 50 add_action( 'woocommerce_update_order', [ '\uAfrica_Shipping\app\WooCommerce', 'save_order_meta' ], 10, 2 ); … … 61 67 $order = is_a( $order, 'WC_Order' ) ? $order : wc_get_order( $order_id ); 62 68 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 64 76 self::include_total_grams_in_order($order_id, $order); 65 77 … … 84 96 85 97 $weight = 0; 86 $cart = WC()->cart; 98 $cart = null; 99 if ( WC()->cart ) { 100 $cart = WC()->cart; 101 } 102 87 103 if ( $cart !== null ) { 88 104 // Grab total weight from cart. … … 677 693 } 678 694 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 } 686 728 } -
uafrica-shipping/trunk/readme.txt
r3305500 r3306198 6 6 Tested up to: 6.7 7 7 Requires PHP: 7.0.0 8 Stable tag: 3.0. 888 Stable tag: 3.0.90 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 78 78 == Changelog == 79 79 80 = 3.0.90 = 81 * Fix handling order meta updates for WooCommerce Subscriptions 82 80 83 = 3.0.88 = 81 84 * Display the estimated delivery date range on the tracking page -
uafrica-shipping/trunk/uafrica-shipping.php
r3305500 r3306198 13 13 * Requires at least: 5.0 14 14 * Requires PHP: 7.0 15 * Version: 3.0. 8815 * Version: 3.0.90 16 16 * License: GPLv2 or later 17 17 * … … 25 25 */ 26 26 27 define( 'UAFRICA_SHIPPING_VERSION', '3.0. 88' );27 define( 'UAFRICA_SHIPPING_VERSION', '3.0.90' ); 28 28 // Endpoints for tracking orders. 29 29 define( '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.