<?php
/**
 * Class Ecre_Single_Product_Tab
 *
 * This class is responsible for customizing single product tabs in WooCommerce.
 *
 * @package ECRE\Frontend
 * @since 1.0.0
 */

namespace ECRE\Frontend;

if ( ! class_exists( 'Ecre_Single_Product_Tab' ) ) {
	/**
	 * The Ecre_Single_Product_Tab class handles singal product custom tab.
	 *
	 * @since 1.0.0
	 */
	class Ecre_Single_Product_Tab {
		/**
		 * The name of the menu.
		 *
		 * @var string
		 */
		private $menu_name;

		/**
		 * Initializes the Ecre_Single_Product_Tab class.
		 *
		 * Sets up class properties using the provided settings and integrates with WooCommerce
		 * to add a custom tab on single product pages displaying referral-related information.
		 *
		 * @param bool  $is_pro            Indicates whether the user has a professional (pro) account.
		 * @param array $erce_settings     The current settings array for configuring the product tab behavior.
		 * @param array $default_settings  The default fallback settings for the product tab.
		 *
		 * @since 1.0.0
		 */
		public function __construct( $is_pro, $erce_settings, $default_settings ) {
			$this->menu_name = $erce_settings['referralMenuName'];

			// Hook into WooCommerce to add a custom tab.
			add_filter( 'woocommerce_product_tabs', array( $this, 'ecre_pro_singal_product_referral_tab' ) );
		}

		/**
		 * Add a custom tab to the single product page
		 *
		 * @param array $tabs Current product tabs.
		 * @return array
		 * @since 1.0.0
		 */
		public function ecre_pro_singal_product_referral_tab( $tabs ) {
			// Add a new tab with the title "Referral Program".
			$tabs['new_tab'] = array(
				'title'    => $this->menu_name,
				'priority' => 50,
				'callback' => array( $this, 'ecre_pro_referral_program_tab_content' ),
			);

			return $tabs;
		}

		/**
		 * Display the content of the custom tab
		 *
		 * @since 1.0.0
		 */
		public function ecre_pro_referral_program_tab_content() {
			?>
				<div class="ecre_single_product_dashboard">
				</div>
			<?php
		}
	}
}
