On this page
Ghost stores prices in the smallest unit of the currency: $9 is saved as 900 cents. The {{price}} helper turns that number into a price people can read, with the right currency symbol and number format for your site’s language.
Portal, Ghost’s built-in sign-up popup, shows your prices for you. You need {{price}} when your theme shows them itself: a custom pricing page, a plan list on the homepage, or a member’s account page.
How it works
Pass it a plan, or an amount and a currency:
{{price plan}}
{{!-- Outputs: $5 --}}That is the same as writing out all the defaults:
{{price plan.amount
currency=plan.currency
locale=@site.locale
numberFormat="short"
currencyFormat="symbol"
}}The first value is the amount, in the smallest unit (cents for dollars and euros). The options are all optional:
currency: the three-letter ISO code, such as"USD"or"EUR". When you pass aplan, it uses the plan’s currency.locale: the language used to format the number. The default is@site.locale, your site’s publication language.numberFormat:"short"($5, the default) or"long"($5.00).currencyFormat:"symbol"($5, the default),"code"(USD 5) or"name"(5 US dollars).
Examples
Prices of your tiers
Fetch your tiers with the {{#get}} helper and show the monthly and yearly price of each. The free tier has no price, so check first:
{{#get "tiers" include="monthly_price,yearly_price,benefits" limit="100"}}
{{#foreach tiers}}
<h3>{{name}}</h3>
{{#if monthly_price}}
<a href="javascript:" data-portal="signup/{{id}}/monthly">
{{price monthly_price currency=currency}}/month
</a>
{{/if}}
{{#if yearly_price}}
<a href="javascript:" data-portal="signup/{{id}}/yearly">
{{price yearly_price currency=currency}}/year
</a>
{{/if}}
{{/foreach}}
{{/get}}Inside {{#foreach tiers}}, monthly_price, yearly_price and currency belong to the current tier. The data-portal links open Portal’s checkout for that tier and billing period.
A member’s subscription
On an account page, loop over the member’s subscriptions:
{{#foreach @member.subscriptions}}
<p>Your plan: {{price plan}}/{{plan.interval}}</p>
{{!-- Outputs: Your plan: $99/year --}}
{{/foreach}}@member is only set for signed-in members, so this shows nothing to visitors.
A fixed amount
You can pass any number, for example a price that isn’t a tier:
{{price 4900 currency="USD"}}
{{!-- Outputs: $49 --}}
{{price 0 currency="USD"}}
{{!-- Outputs: $0 --}}Without an amount, the helper prints only the currency symbol:
{{price currency="EUR"}}
{{!-- Outputs: € --}}When to use it
Use {{price}} whenever your theme prints a price. It keeps the format the same across the site, follows each tier’s currency and your site’s language, and reads the price from the tier, so nothing goes out of date when you change one.
To show different content to free and paid members, wrap it in {{#if @member.paid}}; for other comparisons, use the match helper. To build the sign-up buttons around your prices, see subscription forms in Ghost.