mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Handled dummy subscription for comped members
refs https://github.com/TryGhost/Team/issues/986#issuecomment-900281186 The tiers features updated the "comped" functionality to no longer create a Stripe Subscription for members. Since theme developers expect comped members will have a subscription, we added a dummy subscription object for comped members in API. Since Admin previously expected comped members to be ones without any subscription but access to product, this change updates Admin behavior to identify comped subscriptions on a product and show them the same way as before.
This commit is contained in:
parent
23c6547b5b
commit
b5bc870a3b
2 changed files with 97 additions and 60 deletions
|
@ -145,68 +145,104 @@
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
{{#each product.subscriptions as |sub|}}
|
{{#each product.subscriptions as |sub|}}
|
||||||
<div class="gh-memberproduct-subscription">
|
{{#if sub.isComplimentary}}
|
||||||
<div>
|
<div class="gh-memberproduct-subscription">
|
||||||
<div>
|
<div>
|
||||||
<span class="gh-cp-memberproduct-pricelabel">{{sub.price.nickname}}</span>
|
<div>
|
||||||
–
|
<span class="gh-cp-memberproduct-pricelabel">Complimentary</span>
|
||||||
{{#if sub.cancel_at_period_end}}
|
<span class="gh-badge active">Active</span>
|
||||||
<span class="gh-cp-memberproduct-renewal">Has access until {{sub.validUntil}}</span>
|
</div>
|
||||||
<span class="gh-badge archived">Cancelled</span>
|
<div class="gh-memberproduct-created">Created on</div>
|
||||||
{{else}}
|
|
||||||
<span class="gh-cp-memberproduct-renewal">Renews {{sub.validUntil}}</span>
|
|
||||||
<span class="gh-badge active">Active</span>
|
|
||||||
{{/if}}
|
|
||||||
</div>
|
|
||||||
{{#if sub.cancellationReason}}
|
|
||||||
<div class="gh-memberproduct-cancelreason"><span class="fw6">Cancellation reason:</span> {{sub.cancellationReason}}</div>
|
|
||||||
{{/if}}
|
|
||||||
<div class="gh-memberproduct-created">Created on {{sub.startDate}}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex items-center">
|
|
||||||
<div class="gh-product-card-price">
|
|
||||||
<div class="flex items-start">
|
|
||||||
<span class="currency-symbol">{{sub.price.currencySymbol}}</span>
|
|
||||||
<span class="amount">{{sub.price.nonDecimalAmount}}</span>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="period">{{if (eq sub.price.interval "year") "yearly" "monthly"}}</div>
|
<div class="flex items-center">
|
||||||
</div>
|
<div class="gh-product-card-price">
|
||||||
|
<div class="flex items-start">
|
||||||
<span class="action-menu">
|
<span class="currency-symbol">$</span>
|
||||||
<GhDropdownButton @dropdownName="subscription-menu-{{sub.id}}" @classNames="gh-btn gh-btn-outline gh-btn-icon gh-btn-subscription-action icon-only" @title="Actions">
|
<span class="amount">0</span>
|
||||||
<span>
|
</div>
|
||||||
{{svg-jar "dotdotdot"}}
|
<div class="period">yearly</div>
|
||||||
<span class="hidden">Subscription menu</span>
|
</div>
|
||||||
|
<span class="action-menu">
|
||||||
|
<GhDropdownButton @dropdownName="subscription-menu-complimentary" @classNames="gh-btn gh-btn-outline gh-btn-icon gh-btn-subscription-action icon-only" @title="Actions">
|
||||||
|
<span>
|
||||||
|
{{svg-jar "dotdotdot"}}
|
||||||
|
<span class="hidden">Subscription menu</span>
|
||||||
|
</span>
|
||||||
|
</GhDropdownButton>
|
||||||
|
<GhDropdown @name="subscription-menu-complimentary" @tagName="ul" @classNames="product-actions-menu dropdown-menu dropdown-align-right">
|
||||||
|
<li>
|
||||||
|
<button {{action "removeComplimentary" product.id}}>
|
||||||
|
<span class="red">Remove complimentary subscription</span>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</GhDropdown>
|
||||||
</span>
|
</span>
|
||||||
</GhDropdownButton>
|
</div>
|
||||||
<GhDropdown @name="subscription-menu-{{sub.id}}" @tagName="ul" @classNames="product-actions-menu dropdown-menu dropdown-align-right">
|
</div>
|
||||||
<li>
|
{{else}}
|
||||||
<a href="https://dashboard.stripe.com/customers/{{sub.customer.id}}" target="_blank" rel="noopener">
|
<div class="gh-memberproduct-subscription">
|
||||||
View Stripe customer
|
<div>
|
||||||
</a>
|
<div>
|
||||||
</li>
|
<span class="gh-cp-memberproduct-pricelabel">{{sub.price.nickname}}</span>
|
||||||
<li class="divider"></li>
|
–
|
||||||
<li>
|
{{#if sub.cancel_at_period_end}}
|
||||||
<a href="https://dashboard.stripe.com/subscriptions/{{sub.id}}" target="_blank" rel="noopener">
|
<span class="gh-cp-memberproduct-renewal">Has access until {{sub.validUntil}}</span>
|
||||||
View Stripe subscription
|
<span class="gh-badge archived">Cancelled</span>
|
||||||
</a>
|
{{else}}
|
||||||
</li>
|
<span class="gh-cp-memberproduct-renewal">Renews {{sub.validUntil}}</span>
|
||||||
<li>
|
<span class="gh-badge active">Active</span>
|
||||||
{{#if sub.cancel_at_period_end}}
|
{{/if}}
|
||||||
<button {{action "continueSubscription" sub.id}}>
|
</div>
|
||||||
<span>Continue subscription</span>
|
{{#if sub.cancellationReason}}
|
||||||
</button>
|
<div class="gh-memberproduct-cancelreason"><span class="fw6">Cancellation reason:</span> {{sub.cancellationReason}}</div>
|
||||||
{{else}}
|
|
||||||
<button {{action "cancelSubscription" sub.id}}>
|
|
||||||
<span class="red">Cancel subscription</span>
|
|
||||||
</button>
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</li>
|
<div class="gh-memberproduct-created">Created on {{sub.startDate}}</div>
|
||||||
</GhDropdown>
|
</div>
|
||||||
</span>
|
|
||||||
</div>
|
<div class="flex items-center">
|
||||||
</div>
|
<div class="gh-product-card-price">
|
||||||
|
<div class="flex items-start">
|
||||||
|
<span class="currency-symbol">{{sub.price.currencySymbol}}</span>
|
||||||
|
<span class="amount">{{sub.price.nonDecimalAmount}}</span>
|
||||||
|
</div>
|
||||||
|
<div class="period">{{if (eq sub.price.interval "year") "yearly" "monthly"}}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<span class="action-menu">
|
||||||
|
<GhDropdownButton @dropdownName="subscription-menu-{{sub.id}}" @classNames="gh-btn gh-btn-outline gh-btn-icon gh-btn-subscription-action icon-only" @title="Actions">
|
||||||
|
<span>
|
||||||
|
{{svg-jar "dotdotdot"}}
|
||||||
|
<span class="hidden">Subscription menu</span>
|
||||||
|
</span>
|
||||||
|
</GhDropdownButton>
|
||||||
|
<GhDropdown @name="subscription-menu-{{sub.id}}" @tagName="ul" @classNames="product-actions-menu dropdown-menu dropdown-align-right">
|
||||||
|
<li>
|
||||||
|
<a href="https://dashboard.stripe.com/customers/{{sub.customer.id}}" target="_blank" rel="noopener">
|
||||||
|
View Stripe customer
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="divider"></li>
|
||||||
|
<li>
|
||||||
|
<a href="https://dashboard.stripe.com/subscriptions/{{sub.id}}" target="_blank" rel="noopener">
|
||||||
|
View Stripe subscription
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
{{#if sub.cancel_at_period_end}}
|
||||||
|
<button {{action "continueSubscription" sub.id}}>
|
||||||
|
<span>Continue subscription</span>
|
||||||
|
</button>
|
||||||
|
{{else}}
|
||||||
|
<button {{action "cancelSubscription" sub.id}}>
|
||||||
|
<span class="red">Cancel subscription</span>
|
||||||
|
</button>
|
||||||
|
{{/if}}
|
||||||
|
</li>
|
||||||
|
</GhDropdown>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
||||||
{{#if (and (feature "multipleProducts") (eq product.subscriptions.length 0))}}
|
{{#if (and (feature "multipleProducts") (eq product.subscriptions.length 0))}}
|
||||||
|
|
|
@ -62,7 +62,8 @@ export default class extends Component {
|
||||||
...sub.price,
|
...sub.price,
|
||||||
currencySymbol: getSymbol(sub.price.currency),
|
currencySymbol: getSymbol(sub.price.currency),
|
||||||
nonDecimalAmount: getNonDecimal(sub.price.amount)
|
nonDecimalAmount: getNonDecimal(sub.price.amount)
|
||||||
}
|
},
|
||||||
|
isComplimentary: !sub.id
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue