1

We've currently got Subscriptions setup on a site which works a charm, but my main issue is outputting the price of the subscription, after the user has subscribed.

From the docs/templates I can even see how this is possible?!

You can get it via:

{% set subscriptions = craft.subscriptions.user(currentUser) %}

{% for subscription in subscriptions %}
    {{ subscriptionPlanData.plan.amount }}
{% endfor %}

But if for example, the plan is £300.00 then it outputs as 30000 and when formatted, it comes out like 30,000.00 using {{ subscriptionPlanData.plan.amount|number_format(2, '.', ',') }}

I can't see anyway of showing the user, how much they've paid in a human format without hacking around the number.

2 Answers 2

4

Stripe stores the amount in cents. If you want to format it from the subscriptionPlanData.plan.amount variable in your template you would need to divide by 100 first.

{{ (subscriptionPlanData.plan.amount / 100)|currency }}
2

I could be wrong here as I've not used subscriptions with Commerce yet, but using the filter |currency worked perfectly for me when outputting the correct format after having tried |replace and |number.

1
  • I thought that might have worked, but sadly it still just output £30,000.00 :(
    – Jason Mayo
    Commented Oct 8, 2018 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.