<?php

namespace WPSaad\Elementor\Tags;

use Elementor\Core\DynamicTags\Tag;

if (!defined('ABSPATH')) exit; // Exit if accessed directly

class DokanStoreID extends Tag {

    /**
     * Get tag name
     */
    public function get_name() {
        return 'wpsaad_dokan_store_id';
    }

    /**
     * Get tag title
     */
    public function get_title() {
        return __('Current Dokan Store ID', 'wpsaad-addons-for-dokan-and-elementor');
    }

    /**
     * Get dynamic tag group
     */
    public function get_group() {
        return 'dokan'; // Group it under "Dokan"
    }

    /**
     * Get dynamic tag category
     */
    public function get_categories() {
        return ['text']; // This ensures it appears in numeric fields
    }

    /**
     * Render dynamic tag output
     */
    public function render() {
        if (!function_exists('dokan')) {
            return; // Exit if Dokan is not installed
        }

        // Get the current store vendor ID from query variable
        $store_id = get_query_var('author');

        if ($store_id) {
            echo esc_html($store_id);
        }
    }
}
