| 1 |
<?php namespace TierPricingTable\Integrations\Plugins; |
| 2 |
|
| 3 |
use TierPricingTable\PricingRule; |
| 4 |
|
| 5 |
class AeliaMulticurrency extends PluginIntegrationAbstract { |
| 6 |
|
| 7 |
public function run() { |
| 8 |
add_filter( 'tiered_pricing_table/price/pricing_rule', function ( PricingRule $pricingRule ) { |
| 9 |
|
| 10 |
// Break if Aelia multicurrency is not installed |
| 11 |
if ( ! has_action( 'wc_aelia_cs_convert' ) ) { |
| 12 |
return $pricingRule; |
| 13 |
} |
| 14 |
|
| 15 |
$from_currency = get_option( 'woocommerce_currency' ); |
| 16 |
$to_currency = get_woocommerce_currency(); |
| 17 |
|
| 18 |
if ( $pricingRule->isFixed() ) { |
| 19 |
$_rules = []; |
| 20 |
|
| 21 |
foreach ( $pricingRule->getRules() as $quantity => $price ) { |
| 22 |
$_rules[ $quantity ] = apply_filters( 'wc_aelia_cs_convert', $price, $from_currency, $to_currency ); |
| 23 |
} |
| 24 |
|
| 25 |
$pricingRule->setRules( $_rules ); |
| 26 |
} |
| 27 |
|
| 28 |
return $pricingRule; |
| 29 |
|
| 30 |
}, 9999, 2 ); |
| 31 |
} |
| 32 |
|
| 33 |
public function getTitle(): string { |
| 34 |
return __( 'Aelia Multicurrency', 'tier-pricing-table' ); |
| 35 |
} |
| 36 |
|
| 37 |
public function getAuthorURL(): string { |
| 38 |
return 'https://aelia.co/shop/currency-switcher-woocommerce/'; |
| 39 |
} |
| 40 |
|
| 41 |
public function getIconURL(): string { |
| 42 |
return $this->getContainer()->getFileManager()->locateAsset( 'admin/integrations/aelia-icon.svg' ); |
| 43 |
} |
| 44 |
|
| 45 |
public function getDescription(): string { |
| 46 |
return __( 'Make the tiered pricing properly work with multiple currencies.', 'tier-pricing-table' ); |
| 47 |
} |
| 48 |
|
| 49 |
public function getSlug(): string { |
| 50 |
return 'aelia-multicurrency'; |
| 51 |
} |
| 52 |
|
| 53 |
public function getIntegrationCategory(): string { |
| 54 |
return 'multicurrency'; |
| 55 |
} |
| 56 |
} |
| 57 |
|