{% 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 %}

Available plans

{% for plan in plans %}
{{ redirectInput('shop/services') }} {{ csrfInput() }}

{{ plan.name }}

{% set paymentSources = craft.commerce.getPaymentSources().getAllGatewayPaymentSourcesByUserId(plan.gateway.id, currentUser.id ?? null) %} {% if not paymentSources|length %}
{{ plan.gateway.getPaymentFormHtml({})|raw }}
{% endif %}
{% endfor %}
{% endif %} {% endblock %}