{% extends "commerce/_layouts/cp" %} {% set selectedSubnavItem = "subscriptions" %} {% set bodyClass = (bodyClass is defined ? bodyClass~' ' : '') ~ "commercesubscriptions commercesubscriptionsedit" %} {% set title = subscription %} {% set crumbs = [ { label: "Subscriptions"|t('commerce'), url: url('commerce/subscriptions') } ] %} {% import "_includes/forms" as forms %} {% block header %} {{ block('pageTitle') }}
{% endblock %} {% block content %} {% if fieldLayout is not null and fieldLayout.getTabs()|length %}
{{ csrfInput() }} {# Custom fields pane #}
{% for tab in fieldLayout.getTabs() %} {% endfor %}
{% endif %}

{{ 'Manage subscription'|t('commerce') }}

{% if subscription.gateway.supportsPlanSwitch and not subscription.isCanceled and not subscription.isExpired %} {% set plans = subscription.alternativePlans %} {% set planOptions = [{label: 'Pick a plan'|t('commerce'), value: ''}] %} {% for plan in plans %} {% set planOptions = planOptions|merge([{label: plan.name, value:plan.id}]) %} {% endfor %} {{ forms.selectField({ label: 'Switch plan'|t('commerce'), options: planOptions, id: 'switchPlans' }) }} {% for plan in plans %} {% endfor %} {% else %}
{{ 'Cannot switch plans for this subscription.'|t('commerce') }}
{% endif %} {% if subscription.canReactivate() %}
{{ redirectInput('commerce/subscriptions/'~subscription.id) }} {{ csrfInput() }}
{% endif %}
{% if not subscription.isCanceled and not subscription.isExpired %}

{{ 'Cancel subscription'|t('commerce') }}

{{ redirectInput('commerce/subscriptions/'~subscription.id) }} {{ csrfInput() }} {{ subscription.plan.getGateway().getCancelSubscriptionFormHtml(subscription)|raw }}
{% endif %}

Payment history

{% set payments = subscription.getAllPayments() %} {% for payment in payments %} {% set info = [ { label: "Reference", type: 'code', value: payment.paymentReference }, { label: "Gateway response", type: 'response', value: payment.response|raw }, ] %} {% endfor %}
{{ 'Invoice date'|t('commerce') }} {{ 'Invoice amount'|t('commerce') }} {{ 'Status'|t('commerce') }} {{ 'Info'|t('commerce') }}s
{{ payment.paymentDate|datetime }} {{ payment.paymentCurrency }} {{ payment.paymentAmount }} {{ payment.paid ? 'Paid'|t('commerce') : 'Unpaid'|t('commerce') }}
{{ redirectInput('commerce/subscriptions/' ~ subscription.id) }} {{ csrfInput() }}
{% endblock %} {% block details %}
{{ forms.textField({ label: 'Subscription plan'|t('commerce'), value: subscription.getPlan().name, readonly: true }) }} {{ forms.textField({ label: 'Subscription reference'|t('commerce'), value: subscription.reference, readonly: true }) }}

{{ forms.textField({ label: 'Subscription date'|t('commerce'), value: subscription.dateCreated|datetime, readonly: true }) }} {{ forms.textField({ label: 'Trial days credited'|t('commerce'), value: subscription.trialDays, readonly: true }) }} {% if subscription.trialDays %} {{ forms.textField({ label: 'Trial expiration date'|t('commerce'), value: subscription.trialExpires|datetime, readonly: true }) }} {% endif %}

{{ forms.textField({ label: 'Next payment date'|t('commerce'), value: subscription.nextPaymentDate|datetime, readonly: true }) }} {{ forms.textField({ label: 'Expiry date'|t('commerce'), value: subscription.dateExpired ? subscription.dateExpired|datetime : '-', readonly: true }) }} {{ forms.textField({ label: 'Cancelation date'|t('commerce'), value: subscription.dateCanceled ? subscription.dateCanceled|datetime : '-', readonly: true }) }}
{% endblock %} {% js %} $(document).ready(function () { $('#switchPlans').on('change', function (ev) { $('.switchPlansForm').addClass('hidden'); $('#switch-'+ev.currentTarget.value).removeClass('hidden'); }); $.each($('.tableRowInfo'), function () { new Craft.Commerce.TableRowAdditionalInfoIcon(this); }); }); {% endjs %} {% do view.registerAssetBundle("craft\\web\\assets\\prismjs\\PrismJsAsset") %}