<?php
/**
 * WooCommerce integration.
 *
 * @package MenuVerse
 */

namespace WPXero\MenuVerse\Compat;

defined( 'ABSPATH' ) || exit;

/**
 * Supplies the cart count badge with the endpoint it reads from.
 *
 * MenuVerse never reads the cart itself. WooCommerce already exposes a public
 * Store API route for exactly this, and a cart total is per visitor, so asking
 * the browser for it is both simpler and safe under a full page cache.
 */
class Woo implements Integration {

	/**
	 * Returns the integration identifier.
	 *
	 * @return string
	 */
	public static function id() {
		return 'woocommerce';
	}

	/**
	 * Returns the translated plugin name.
	 *
	 * @return string
	 */
	public static function label() {
		return __( 'WooCommerce', 'menuverse' );
	}

	/**
	 * Tells whether WooCommerce is active.
	 *
	 * @return bool
	 */
	public static function is_active() {
		return class_exists( 'WooCommerce' );
	}

	/**
	 * Returns the Store API cart endpoint, or an empty string when inactive.
	 *
	 * @return string
	 */
	public static function cart_url() {
		return self::is_active() ? rest_url( 'wc/store/v1/cart' ) : '';
	}
}
