<?php
/**
 * Groups sync functions.
 *
 * @package flo-sync
 */

namespace NMFS\Sync\Items\Groups;

use NMFS\Admin\Settings_Fields;
use NMFS\Shared;

defined( 'ABSPATH' ) || exit;

/**
 * Groups class.
 */
class Groups {

	/**
	 * Checks if the sync is enabled
	 */
	public static function is_enabled(): bool {
		return Shared::instance()->admin->settings->is_setting_enabled( Settings_Fields::SYNC_PRODUCT_CATEGORIES );
	}

	/**
	 * Retrieves the hub ID by post ID
	 *
	 * @param int $post_id The post ID.
	 *
	 * @return string|null The hub ID if found, null otherwise
	 */
	public static function get_hub_id_by_post_id( int $post_id ): ?string {
		return get_term_meta( $post_id, Sync_Groups::META_KEY_GROUP_ID, true );
	}
}
