<?php

namespace DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Integration;

use WC_Product;
class EanIntegration
{
    const META_KEY = '_global_unique_id';
    public static function is_active(): bool
    {
        return is_plugin_active('flexible-ean-for-woocommerce/flexible-ean-for-woocommerce.php');
    }
    public static function should_display_ean(): bool
    {
        return self::is_active() || defined('WC_VERSION') && version_compare(\WC_VERSION, '9.2.0', '>=');
    }
    public static function get_ean_field(WC_Product $product): ?string
    {
        if (defined('WC_VERSION') && version_compare(\WC_VERSION, '9.2.0', '>=')) {
            return $product->get_global_unique_id();
        }
        return $product->get_meta(self::META_KEY);
    }
}
