get_exchange_rate_price( $amount ); } if ( method_exists( $zone, 'get_exchange_rate' ) ) { return $amount * (float) $zone->get_exchange_rate(); } } return $amount; } $base = self::base(); $current = self::current(); if ( $base === $current ) { return $amount; } // WPML / WooCommerce Multilingual. if ( has_filter( 'wcml_raw_price_amount' ) ) { return (float) apply_filters( 'wcml_raw_price_amount', $amount, $current ); // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment } // Aelia Currency Switcher. if ( has_filter( 'wc_aelia_cs_convert' ) ) { return (float) apply_filters( 'wc_aelia_cs_convert', $amount, $base, $current ); // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment } // CURCY – WooCommerce Multi Currency. if ( function_exists( 'wmc_get_price' ) ) { return (float) wmc_get_price( $amount ); } // WOOCS / FOX Currency Switcher. if ( isset( $GLOBALS['WOOCS'] ) && is_object( $GLOBALS['WOOCS'] ) && method_exists( $GLOBALS['WOOCS'], 'woocs_exchange_value' ) ) { return (float) $GLOBALS['WOOCS']->woocs_exchange_value( $amount ); } return $amount; } /** * Whether a currency plugin converts fixed coupon amounts by itself (then the reward coupon is * given its amount in the base currency, or it would be converted twice). */ public static function coupon_amounts_converted_by_others(): bool { $key = 'coupon|' . self::current(); if ( ! isset( self::$cache[ $key ] ) ) { $probe = new \WC_Coupon(); $probe->set_discount_type( 'fixed_cart' ); $probe->set_amount( 100 ); self::$cache[ $key ] = abs( (float) $probe->get_amount() - 100 ) > 0.0001; } return self::$cache[ $key ]; } /** * The amount a fixed reward coupon should carry. * * @param float $amount Amount in the base currency. */ public static function coupon_amount( float $amount ): float { return self::coupon_amounts_converted_by_others() ? $amount : self::convert( $amount ); } /** * The minimum amount of a free shipping method, in the customer's currency. * * @param \WC_Shipping_Method $method Free shipping method instance. */ public static function free_shipping_minimum( $method ): float { $raw = (float) wc_format_decimal( (string) ( $method->instance_settings['min_amount'] ?? $method->get_option( 'min_amount' ) ) ); $read = (float) wc_format_decimal( (string) $method->get_option( 'min_amount' ) ); // A currency plugin that filters the option already converted it. return abs( $read - $raw ) > 0.0001 ? $read : self::convert( $raw ); } }