<?php
/**
 * Free package capabilities.
 *
 * @package DreamFast_CF
 */

namespace DreamFast\CommerceFloat;

defined( 'ABSPATH' ) || exit;

/**
 * Free feature metadata.
 */
class Features {

	const DB_VERSION_OPTION = 'dreamfast_cf_db_version';

	/**
	 * Whether the current package is premium.
	 *
	 * @return bool
	 */
	public static function is_premium_package() {
		return false;
	}

	/**
	 * Premium features are not present in the free package.
	 *
	 * @return bool
	 */
	public static function is_pro() {
		return false;
	}

	/**
	 * Get the upgrade URL.
	 *
	 * @return string
	 */
	public static function get_upgrade_url() {
		return (string) apply_filters( 'dreamfast_cf_upgrade_url', DREAMFAST_CF_PRO_UPGRADE_URL );
	}

	/**
	 * Track the installed data version.
	 */
	public static function maybe_migrate() {
		$stored = (string) get_option( self::DB_VERSION_OPTION, '0' );
		if ( version_compare( $stored, DREAMFAST_CF_VERSION, '>=' ) ) {
			return;
		}

		update_option( self::DB_VERSION_OPTION, DREAMFAST_CF_VERSION );
	}

	/**
	 * Check a free feature slug.
	 *
	 * @param string $feature Feature slug.
	 * @return bool
	 */
	public static function can_use( $feature ) {
		return in_array(
			$feature,
			array(
				'sticky_cart',
				'contact_whatsapp',
				'cart_presets',
			),
			true
		);
	}
}
