diff --git a/includes/compats/class-wc-amazon-payments-advanced-multi-currency-aelia-currency-switcher.php b/includes/compats/class-wc-amazon-payments-advanced-multi-currency-aelia-currency-switcher.php new file mode 100644 index 00000000..dc7ecbcc --- /dev/null +++ b/includes/compats/class-wc-amazon-payments-advanced-multi-currency-aelia-currency-switcher.php @@ -0,0 +1,68 @@ +currency_switcher = $GLOBALS['woocommerce-aelia-currencyswitcher']; + add_filter( 'init', array( $this, 'remove_shortcode_currency_switcher_on_order_reference_suspended' ) ); + + parent::__construct(); + } + + + /** + * Get the selected currency from the Currency Switcher. + * + * @return string + */ + public function get_selected_currency() { + return $this->currency_switcher->get_selected_currency(); + } + + /** + * The name of this method is misleading. It should return "true" if the multi-currency + * plugin only DISPLAYS prices in multiple currencies, but the transactions occur in + * a single currency. The Aelia Currency Switcher always ensures that transactions are + * completed in the currency used to place an order, therefore this method should return + * false. + * + * @return bool + */ + public function is_front_end_compatible() { + return false; + } + + /** + * On OrderReferenceStatus === Suspended, hide currency switcher. + */ + // TODO Clarify what this method does + public function remove_shortcode_currency_switcher_on_order_reference_suspended( $value ) { + if ( $this->is_order_reference_checkout_suspended() ) { + // By Pass Multi-currency, so we don't trigger a new set_order_reference_details on process_payment + $this->bypass_currency_session(); + } + } + +} diff --git a/includes/compats/class-wc-amazon-payments-advanced-multi-currency.php b/includes/compats/class-wc-amazon-payments-advanced-multi-currency.php index 89794afc..751b5e16 100644 --- a/includes/compats/class-wc-amazon-payments-advanced-multi-currency.php +++ b/includes/compats/class-wc-amazon-payments-advanced-multi-currency.php @@ -19,6 +19,16 @@ class WC_Amazon_Payments_Advanced_Multi_Currency { * List of compatible plugins, with its global variable name or main class. */ const COMPATIBLE_PLUGINS = array( + // Aelia Currency Switcher + // + // Note + // The Aelia Currency Switcher integration must come before the WooCommerce Multilingual one. + // This is needed because this integration class stops as soon as it finds one of the supported + // plugins. If it finds the WooCommerce Multilingual, it will not look for any other, even if + // the multi-currency features in WCML are disabled. In that case, the integration with the + // Aelia Currency Switcher would not be loaded, even though the plugin is active and running. + // @author Aelia + 'class_Aelia\WC\CurrencySwitcher\WC_Aelia_CurrencySwitcher' => 'Aelia Currency Switcher', 'global_WOOCS' => 'WOOCS – Currency Switcher for WooCommerce', 'class_WC_Product_Price_Based_Country' => 'Price Based on Country for WooCommerce', 'global_woocommerce_wpml' => 'WPML WooCommerce Multilingual', @@ -68,6 +78,12 @@ public static function init( $region = null ) { require_once 'class-wc-amazon-payments-advanced-multi-currency-wccw.php'; self::$compatible_instance = new WC_Amazon_Payments_Advanced_Multi_Currency_Converted_Widget(); break; + // Aelia Currency Switcher + // @author Aelia + case 'class_Aelia\WC\CurrencySwitcher\WC_Aelia_CurrencySwitcher': + require_once 'class-wc-amazon-payments-advanced-multi-currency-aelia-currency-switcher.php'; + self::$compatible_instance = new WC_Amazon_Payments_Advanced_Multi_Currency_Aelia_Currency_Switcher(); + break; } } } @@ -87,7 +103,7 @@ public static function compatible_region( $region = null ) { /** * Singleton to get if there is a compatible instance running. Region can be injected. - * + * * @param bool $region * * @return WC_Amazon_Payments_Advanced_Multi_Currency_Abstract