Files
roi-theme/wp-content/plugins/wp-marketing-automations/woofunnels/compatibilities/class-bwf-compatibility-with-wc-price-based-on-country.php
root a22573bf0b Commit inicial - WordPress Análisis de Precios Unitarios
- WordPress core y plugins
- Tema Twenty Twenty-Four configurado
- Plugin allow-unfiltered-html.php simplificado
- .gitignore configurado para excluir wp-config.php y uploads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-03 21:04:30 -06:00

63 lines
1.4 KiB
PHP
Executable File

<?php
if ( ! class_exists( 'BWF_Compatibility_With_WC_Price_Based_On_Country' ) ) {
#[AllowDynamicProperties]
class BWF_Compatibility_With_WC_Price_Based_On_Country {
public function is_enable() {
return class_exists( 'WC_Product_Price_Based_Country' );
}
/**
*
* Modifies the amount for the fixed discount given by the admin in the currency selected.
*
* @param integer|float $price
*
* @return float
*/
public function alter_fixed_amount( $price, $currency = null ) {
if ( ! $this->is_enable() ) {
return $price;
}
$rate = $this->get_exchange_rate( $currency );
return $price * $rate;
}
public function get_fixed_currency_price_reverse( $price, $currency = null, $base = null ) {
if ( ! $this->is_enable() ) {
return $price;
}
$rate = $this->get_exchange_rate( $currency );
return $price / $rate;
}
/**
* Get exchange rate
*
* @param $currency
*
* @return float|int
*/
public function get_exchange_rate( $currency ) {
if ( ! class_exists( 'WCPBC_Pricing_Zones' ) ) {
return 1;
}
$zones = WCPBC_Pricing_Zones::get_zones();
foreach ( $zones as $zone ) {
/** @var $zone WCPBC_Pricing_Zone */
if ( $currency !== $zone->get_currency() ) {
continue;
}
return $zone->get_exchange_rate();
}
return 1;
}
}
BWF_Plugin_Compatibilities::register( new BWF_Compatibility_With_WC_Price_Based_On_Country(), 'wc_price_based_on_country' );
}