{% extends "_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') }}
{% block actionButton %}
{% endblock %} {% endblock %} {% block content %}

{{ '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(continueEditingUrl) }} {{ csrfInput() }}
{% endif %}
{% if not subscription.isCanceled and not subscription.isExpired %}

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

{{ redirectInput(continueEditingUrl) }} {{ 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(continueEditingUrl) }} {{ csrfInput() }}
{{ redirectInput('commerce/subscriptions') }} {{ csrfInput() }} {% if fieldLayout is not null and fieldLayout.getTabs()|length %} {% for tab in fieldLayout.getTabs() %} {% endfor %} {% endif %}
{% endblock %} {% block details %}
User

{{subscription.subscriber.fullName ? subscription.subscriber.fullName : subscription.subscriber.friendlyName}}


{{ forms.textField({ label: 'Plan'|t('commerce'), value: subscription.getPlan().name, readonly: true }) }} {{ forms.textField({ label: 'Reference'|t('commerce'), value: subscription.reference, readonly: true }) }} {{ forms.textField({ label: 'Created'|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'|t('commerce'), value: subscription.trialExpires|datetime, readonly: true }) }} {% endif %} {{ forms.textField({ label: 'Next payment'|t('commerce'), value: subscription.nextPaymentDate|datetime, readonly: true }) }} {{ forms.textField({ label: 'Expiry'|t('commerce'), value: subscription.dateExpired ? subscription.dateExpired|datetime : '-', readonly: true }) }} {{ forms.textField({ label: 'Cancellation'|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); }); $('#saveCustomFieldsSubmit').click(function(){ $('form#customFields').submit(); }); }); {% endjs %} {% do view.registerAssetBundle("craft\\web\\assets\\prismjs\\PrismJsAsset") %}