<?php

declare(strict_types=1);

namespace CloudXM\SDK\WooCommerce\Compatibility;

/**
 * Helper trait to mark plugin as compatible with WooCommerce Cart & Checkout Blocks.
 */
class BlocksCompatibility
{
    /** Register callback on before_woocommerce_init to declare support. */
    public static function hook(string $pluginFile): void
    {
        add_action('before_woocommerce_init', function () use ($pluginFile) {
            if (class_exists('\\Automattic\\WooCommerce\\Utilities\\FeaturesUtil')) {
                \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility(
                    'cart_checkout_blocks',
                    $pluginFile,
                    true
                );
            }
        });
    }
}
