{% extends 'shop/_layouts/main' %} {% block main %} {% set plans = craft.commerce.getPlans().getAllPlans() %} {% if currentUser and plans|length%} {% for plan in plans %}

{{ plan.name }}

{% set information = plan.getInformation() %}
{% set subscriptions = plan.getActiveUserSubscriptions(currentUser.id) %} {% if subscriptions|length == 0 %}

You have no subscriptions to this plan.

{% endif %} {% if subscriptions|length > 1 %}

You have multiple subscriptions to this plan.

{% endif %} {% for subscription in subscriptions %} {% if subscription.isCanceled %} Your subscription was canceled on {{ subscription.dateCanceled|date('Y-m-d') }} and will expire on {{ subscription.nextPaymentDate|date('Y-m-d') }} {% else %} You are subscribed and your next payment is due on {{ subscription.nextPaymentDate|date('Y-m-d') }} {% endif %}

Manage subscription

{% endfor %}
{% if loop.last %}
{% endif %} {% endfor %}

Subscribe

{{ redirectInput('shop/services') }} {{ csrfInput() }}
{% set plan = plans[0] %} {# Since only stripe currently supports subscriptions, we can get away with non-gateway-specific subscription forms #} {{ plan.gateway.subscriptionFormHtml|raw }} {% set paymentSources = craft.commerce.getPaymentSources().getAllGatewayPaymentSourcesByUserId(plan.gateway.id, currentUser.id ?? null) %} {% if not paymentSources|length %}
{{ plan.gateway.getPaymentFormHtml({})|raw }}
{% endif %}
{% endif %} {% endblock %}