<?php

namespace Objectiv\Plugins\Checkout\Compatibility\Plugins;

class NexcessMU {
	public function init( bool $side_cart_enabled ) {
		if ( ! defined( 'NEXCESS_MAPPS_SITE' ) ) {
			return;
		}

		if ( ! $side_cart_enabled ) {
			return;
		}

		add_action( 'wp_enqueue_scripts', array( $this, 'prevent_disable_fragments' ), 1 );
	}

	public function prevent_disable_fragments() {
		$instance = cfw_get_hook_instance_object( 'wp_enqueue_scripts', 'dequeueCartFragments', 20 );

		if ( ! $instance ) {
			cfw_debug_log( 'Instance not found ' );
			return;
		}

		remove_action( 'wp_enqueue_scripts', array( $instance, 'dequeueCartFragments' ), 20 );
	}
}
