<?php
/**
 * StoreMultiCurrency — detects whether the store runs in multi-currency mode.
 *
 * @package CartCue
 */

namespace CartCue;

defined( 'ABSPATH' ) || exit;

final class StoreMultiCurrency {

	/**
	 * Whether currency-based play conditions are relevant for this store.
	 */
	public static function is_enabled(): bool {
		$filtered = apply_filters( 'cartcue_is_multi_currency_store', null );
		if ( null !== $filtered ) {
			return (bool) $filtered;
		}

		if ( defined( 'WCML_VERSION' ) || defined( 'WOOCS_VERSION' ) ) {
			return true;
		}

		if ( class_exists( 'WC_Multi_Currency' ) ) {
			return true;
		}

		if ( class_exists( '\Aelia\WC\CurrencySwitcher\WC_Aelia_CurrencySwitcher' ) ) {
			return true;
		}

		if ( class_exists( '\WCPay\MultiCurrency\MultiCurrency' ) ) {
			return true;
		}

		if ( class_exists( '\Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks\WooCommercePayments' ) ) {
			// WooCommerce Payments multi-currency stores option when enabled.
			$enabled = get_option( 'wcpay_multi_currency_enabled', '' );
			if ( 'yes' === $enabled || '1' === $enabled ) {
				return true;
			}
		}

		return false;
	}
}
