Here you can find a list of helper methods provided by Spree that are available in the Storefront that you can use in every template.

The list is incomplete. We’re working on it!

current_currency

Returns the currently selected currency. By default in the Storefront this will be store.default_currency. This can be changed in the Settings -> Store Defaults page.

<%= current_currency %>

will return

USD

current_locale

Returns the currently selected locale. By default in the Storefront this will be store.default_locale. This can be changed in the Settings -> Store Defaults page. If there are multiple locales available, it will return the locale that is currently selected by the user.

<%= current_locale %>

Locale also affects the storefront URLs. For example, if the default locale is en and the user selects fr, the URL will be /fr/products/123.

current_order

current_order
Spree::Order

Returns the current order object. If no order is found, it will return nil.

Order is automatically created when a user adds a product to the cart.

current_store

current_store
Spree::Store

Returns the current store Spree::Store instance.

current_theme

current_theme
Spree::Theme

Returns the current theme Spree::Theme instance.

local_time

Displays a time in the user’s timezone in a human readable format (based on the browser’s timezone).

<%= local_time(order.sent_to_erp_at) %>

Provided by local_time gem.

supported_currencies

Returns the list of supported currencies for the current store as an array of strings.

<%= supported_currencies %>

will return

["USD", "EUR"]

try_spree_current_user

try_spree_current_user
Spree.user_class

Returns the current user object (class depends on the Spree.admin_user_class configuration). If the user is not signed in, it will return nil.

If you want to check if the user is signed in, you can use the following:

<%= try_spree_current_user.present? %>