From 21d5fa8e546741f4cf62968342d135e966f642c9 Mon Sep 17 00:00:00 2001 From: J7 Date: Thu, 2 Jan 2025 19:13:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=81=B8=E6=93=87=E6=9C=80=E5=B0=8F?= =?UTF-8?q?=E9=81=8B=E8=B2=BB=EF=BC=8C=E9=81=8B=E9=80=81=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E6=B6=88=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/class-woomp-shipping-flat-rate.php | 64 ------------------------ public/class-woomp-checkout.php | 2 +- woomp.php | 2 +- 3 files changed, 2 insertions(+), 66 deletions(-) diff --git a/admin/class-woomp-shipping-flat-rate.php b/admin/class-woomp-shipping-flat-rate.php index b810148..7c52c52 100644 --- a/admin/class-woomp-shipping-flat-rate.php +++ b/admin/class-woomp-shipping-flat-rate.php @@ -184,70 +184,6 @@ public function init() { add_action( 'admin_footer', [ $this, 'enqueue_admin_js' ], 10 ); } - /** - * 檢查運送方式是否可用 - * - * @param array $package 運送包裹資訊. - * @return bool - */ - public function is_available( $package ) { - $has_coupon = false; - $has_met_min_amount = false; - - $requires = $this->requires ?? $this->cost_requires ?? ''; - - if ( in_array( $requires, [ 'coupon', 'either', 'both' ], true ) ) { - $coupons = WC()->cart->get_coupons(); - - if ( $coupons ) { - foreach ( $coupons as $code => $coupon ) { - if ( $coupon->is_valid() && $coupon->get_free_shipping() ) { - $has_coupon = true; - break; - } - } - } - } - - if ( in_array( $requires, [ 'min_amount', 'either', 'both' ], true ) ) { - $total = WC()->cart->get_displayed_subtotal(); - - if ( WC()->cart->display_prices_including_tax() ) { - $total = $total - WC()->cart->get_discount_tax(); - } - - if ( 'no' === $this->ignore_discounts ) { - $total = $total - WC()->cart->get_discount_total(); - } - - $total = NumberUtil::round( $total, wc_get_price_decimals() ); - - if ( $total >= $this->min_amount ) { - $has_met_min_amount = true; - } - } - - switch ( $requires ) { - case 'min_amount': - $is_available = $has_met_min_amount; - break; - case 'coupon': - $is_available = $has_coupon; - break; - case 'both': - $is_available = $has_met_min_amount && $has_coupon; - break; - case 'either': - $is_available = $has_met_min_amount || $has_coupon; - break; - default: - $is_available = true; - break; - } - - return apply_filters( 'woocommerce_shipping_' . $this->id . '_is_available', $is_available, $package, $this ); - } - /** * 計算運費金額 * diff --git a/public/class-woomp-checkout.php b/public/class-woomp-checkout.php index 6acd4f4..fa73fa0 100644 --- a/public/class-woomp-checkout.php +++ b/public/class-woomp-checkout.php @@ -425,7 +425,7 @@ public static function get_diff_amount( $method, $check_requires_list, $original */ public static function get_diff_amount_by_settings( $settings, $check_requires_list, $original = false ): float|null { - $requires = $settings['cost_requires'] ?? ( $settings['requires'] ?? '' ); + $requires = @$settings['cost_requires'] ?: @$settings['requires']; $ignore_discounts = $settings['ignore_discounts'] ?? 'no'; $min_amount = $settings['min_amount'] ?? 0; diff --git a/woomp.php b/woomp.php index e9efb34..27beebe 100644 --- a/woomp.php +++ b/woomp.php @@ -4,7 +4,7 @@ * Plugin Name: 好用版擴充 MorePower Addon for WooCommerce * Plugin URI: https://morepower.club/morepower-addon/ * Description: WooCommerce 好用版擴充,改善結帳流程與可變商品等區塊,並整合多項金流,讓 WooCommerce 更符合亞洲人使用習慣。 - * Version: 3.4.53 + * Version: 3.4.54 * Author: MorePower * Author URI: https://morepower.club * License: GPL-2.0+