✨ Flair — a modern, stylish theme for your blogExplore

Ghost CMS Price Helper Overview & Tips

How to use the price helper in your Ghost theme. Overview of the available options and specific use cases with examples on what you can do with the helper.

Norbert
Norbert3 min read

The price helper is a function in Ghost that allows you to display prices on your website in a consistent and user-friendly format. Ghost handles this automatically in Portal, but if you have a custom membership page, or another place to show your membership plans or tiers then you have to use the {{price}} helper.

Price helper options

The Ghost price helper comes with a number of options that you can use to customize the display of prices. Here are the options available:

  • amount - the amount option allows you to specify the numerical value of the price. This value can be an integer or a decimal number, depending on the level of precision required.
  • currency - the currency option allows you to specify the currency in which the price will be displayed. You can use the three-letter ISO currency code to specify the currency, such as "USD" for US dollars or "EUR" for Euros.
  • locale - the locale options allows you to change format of the price, based on the language, the default is "@site.locale"
  • numberFormat - the numberFormat option allows you to define the price precision. You can use "short" or "long", with "short" being the default value.
  • currencyFormat - the currencyFormat option allows you to specify the currency format for the price. This can be either "symbol" or "code", "symbol" being the default value.

By using these options, you can customize the display of prices on your Ghost website to suit your needs and preferences. You can also use these options in combination with each other to achieve the desired display format for your prices.

Now let's see some examples with specific use cases.

Price helper use case & examples

Basic usage:

{{price plan}}

This will display a members price plan. Here's the more advanced usage of the helper:

{{price
  plan.amount
  currency=plan.currency
  locale=@site.locale
  numberFormat='short'
  currencyFormat='symbol'
}}

Now let's seem some more specific use cases for the price helper.

  1. Display a members subscription plan:
{{#foreach @member.subscriptions}}
  {{price plan}}/{{plan.interval}}
  <!-- Outputs: $99/year -->
{{/foreach}}

For this to work, you have to be in the right context, in this case it's @member.subscriptions.

  1. Display a membership tier monthly or yearly price:
{{#get 'tiers' include='monthly_price,yearly_price,benefits'}}
  {{#foreach tiers}}
    {{price monthly_price currency=currency}}
    <!-- Outputs: $9/month -->
  {{/foreach}}
{{/get}}
{{#get 'tiers' include='monthly_price,yearly_price,benefits'}}
  {{#foreach tiers}}
    {{price yearly_price currency=currency}}
    <!-- Outputs: $99/year -->
  {{/foreach}}
{{/get}}

In both cases you have to be in the right context, which in this case is the tiers object.

  1. Display a static price:
{{price 0 currency='USD'}}
<!-- Outputs: $0 -->

Conclusions

Overall, the Ghost price helper is a useful tool for displaying prices on your website in a consistent and user-friendly format. By using the options and customization features available in the price helper, you can tailor the display of prices to suit your business needs and preferences.

More in Tips & Tricks

All tips

Ghost CMS Match Helper Usage & Tips

How to use the match helper in your Ghost theme. Overview of the available operators and specific use cases with examples on what you can do with this helper.

Ghost Pro Hosting

Get the best managed Ghost CMS hosting and focus on bringing value to your audience.