<?php
/**
 * Buy Now extension — loader / orchestrator.
 *
 * Registers the redirect-engine hooks when the extension is enabled. Classic
 * rendering hooks are wired here in a later phase. Required by
 * `WooCommerceLoader` (already `is_wc_installed()`-gated) and self-instantiated
 * at file end, matching the theme's WooCommerce classes.
 *
 * @package Brandy\WooCommerce\BuyNow
 */

namespace Brandy\WooCommerce\BuyNow;

use Brandy\Traits\SingletonTrait;

defined( 'ABSPATH' ) || exit;

class BuyNowLoader {

	use SingletonTrait;

	protected function __construct() {
		if ( ! Settings::is_enabled() ) {
			return;
		}

		// Native single-product form path.
		add_action( 'woocommerce_add_to_cart', array( RedirectEngine::class, 'capture_cart_key' ), 10, 1 );
		add_filter( 'woocommerce_add_to_cart_redirect', array( RedirectEngine::class, 'filter_add_to_cart_redirect' ), 10, 1 );

		// Classic (PHP-template) rendering surfaces.
		ClassicRenderer::get_instance();
	}
}

BuyNowLoader::get_instance();
