{# ============================================================================= Feature Gate Macros Provides macros for tier-based feature gating in templates. Uses Alpine.js $store.features for dynamic checking. Usage: from "shared/macros/feature_gate.html" import feature_gate, feature_locked, upgrade_banner Show content only if feature is available: call feature_gate("analytics_dashboard")
Analytics content here
endcall Show locked state with upgrade prompt: feature_locked("analytics_dashboard", "Analytics Dashboard", "View advanced analytics") Show upgrade banner: upgrade_banner("analytics_dashboard") ============================================================================= #} {# ============================================================================= Feature Gate Container Shows content only if feature is available Parameters: - feature_code: The feature code to check - fallback: Optional fallback content when feature is not available ============================================================================= #} {% macro feature_gate(feature_code, show_fallback=true) %}
{{ caller() }}
{% if show_fallback %}
{{ feature_locked(feature_code) }}
{% endif %} {% endmacro %} {# ============================================================================= Feature Locked Card Shows a card explaining the feature is locked with upgrade prompt Parameters: - feature_code: The feature code - title: Optional title override - description: Optional description override - show_upgrade_button: Whether to show upgrade button (default true) ============================================================================= #} {% macro feature_locked(feature_code, title=none, description=none, show_upgrade_button=true) %}
{# Lock icon #}
{# Title #}

{% if title %} {{ title }} {% else %} Premium Feature {% endif %}

{# Description #}

{% if description %} {{ description }} {% else %} This feature requires a plan upgrade. {% endif %}

{# Tier badge #}

Available on higher tier plan

{% if show_upgrade_button %} {# Upgrade button #} Upgrade Plan {% endif %}
{% endmacro %} {# ============================================================================= Upgrade Banner Inline banner for upgrade prompts Parameters: - feature_code: The feature code - message: Optional custom message ============================================================================= #} {% macro upgrade_banner(feature_code, message=none) %}

{% if message %} {{ message }} {% else %} Upgrade to unlock this feature {% endif %}

Upgrade
{% endmacro %} {# ============================================================================= Feature Badge Small badge to show feature tier requirement Parameters: - feature_code: The feature code ============================================================================= #} {% macro feature_badge(feature_code) %} Pro {% endmacro %} {# ============================================================================= Sidebar Item with Feature Gate Sidebar navigation item that shows lock if feature not available Parameters: - feature_code: The feature code - href: Link URL - icon: Icon name - label: Display label - current_page: Current page for active state ============================================================================= #} {% macro sidebar_item_gated(feature_code, href, icon, label, current_page='') %} {% endmacro %} {# ============================================================================= UPGRADE PROMPT MACROS ============================================================================= #} {# ============================================================================= Usage Limit Warning Shows warning banner when approaching or at a limit Parameters: - metric_name: One of "orders", "products", "team_members" ============================================================================= #} {% macro limit_warning(metric_name) %}
{% endmacro %} {# ============================================================================= Usage Progress Bar Shows compact progress bar for a limit Parameters: - metric_name: One of "orders", "products", "team_members" - label: Display label ============================================================================= #} {% macro usage_bar(metric_name, label) %}
{{ label }}
{% endmacro %} {# ============================================================================= Upgrade Card Shows upgrade recommendation card (for dashboard) Only shows if there are upgrade recommendations Parameters: - class: Additional CSS classes ============================================================================= #} {% macro upgrade_card(class='') %}
{% endmacro %} {# ============================================================================= Limit Check Button Button that checks limit before action Parameters: - limit_type: One of "orders", "products", "team_members" - action: JavaScript to execute if limit allows - label: Button label - class: Additional CSS classes ============================================================================= #} {% macro limit_check_button(limit_type, action, label, class='') %} {% endmacro %} {# ============================================================================= Tier Badge Shows current tier as a badge Parameters: - class: Additional CSS classes ============================================================================= #} {% macro tier_badge(class='') %} {% endmacro %} {# ============================================================================= Quick Upgrade Link Simple upgrade link that appears when limits are reached ============================================================================= #} {% macro quick_upgrade_link() %} Upgrade to {% endmacro %} {# ============================================================================= Email Settings Warning Shows warning banner when store email settings are not configured. This banner appears at the top of store pages until email is configured. Usage: {{ email_settings_warning() }} ============================================================================= #} {% macro email_settings_warning() %}

Email not configured

Configure your email settings to send order confirmations and customer notifications.

Configure Email
{% endmacro %}