Page variables are available to the theme at run time to be referenced via Jinja.
For example a page variable named store
with an attribute of name can be referenced like this:
{{ store.name }}
Many variables (such as store
) are available to every page. There are certain special variables that are only available on specific pages. These are outlined below.
Global Page Variables
These variables are accessible from every page on your storefront.
Variable Name | Type | Note |
---|---|---|
slug | String | First part of the path for current page (so "index" for index, "subscribe" for "/subscribe/", "customer" for "/customer/thank_you") |
path | String | The full path of the current request minus the slug and minus any GET arguments and the domain. The path for "http://yourstore.com/customer/thank_you" is "thank_you" |
store | Store | The current storefront's Store object. |
guest | Boolean | True if the visitor is anonymous, False if logged in. |
customer | Customer | Only present when the customer is logged in (guest is False). |
custom_domain | String | The custom domain set up for your storefront (such as "www.mystore.com"). |
cratejoy_domain | String | The cratejoy subdomain for your storefront (such as yourstore.cratejoy.com). |
test_mode | Boolean | True if the store is in test mode, False otherwise. |
settings | Object | The theme settings for the current installed theme. |
args | dict | Any arguments that were specified on this request via the query string (such as ?product_id=2323). |
Subscribe Page Variables
Certain pages of your storefront automatically have additional special variables made available to them.
Subscribe
Found in html/subscribe.html
The subscribe page has a unique function called the "Subscribe flow" which must be understood to customize your store's subscription signup process. You can read about this on the Subscribe Flow documentation.
steps
steps
is an array of tuples which serves to tell the subscribe page where in the signup process the user currently is.
If the user has not yet chosen a product they will be at the url yourstore.com/subscribe. In this example all variants available on all products are listed as potential steps, because no product has been chosen.
steps contains:
[
('product', None),
('variant', VariantType1),
('variant', VariantType2),
('term', None)
]
If the user has already chosen a product (or if your store only has a single product and the product is auto-chosen) and there are variants on that product they will be at a url like yourstore.com/subscribe/2323_Product+1. There will be no product step (because it's chosen already, and the variant steps will only be the variants for that particular product.
[
('variant', VariantType1),
('term', None)
]
If the order is a gift order the variant steps are omitted as the recipient chooses the variants on a gift order
cur_step
cur_step
is an integer that represents the customer's progress through the Subscribe Flow. When no product has been chosen it is 0, after a product is chosen it is 1, when the first variant is specified it is 2, etc.
product
product
is a Product object which is present if the user has already chosen a product at this stage in the subscribe flow. If they have not chosen a product yet product
will be None.
instance
instance
is a ProductInstance object that is only present if the user has fully chosen the Product and all of it's variants. Typically this is only available on the term
stage, but it may also be present on the survey
stage if used.
chosen_values
chosen_values
is a list of VariantValue objects that have been chosen by the user. These are appended to the url as per the Subscribe Flow documentation.
possible_values
possible_values
is a list of VariantValue objects that apply to the next unspecified variant, ie unspecified_variants[0]
. This list is the set of options a user must choose from when specifying the next variant.
unspecified_variants
unspecified_variants
is a list of VariantType objects that are on the current chosen product
but have not had their value chosen by the user (and inserted into chosen_values
). unspecified_variants[0]
represents the next variant to be chosen by the user.
stage
stage
is a String that indicates the current stage in the Subscribe Flow.
It's possible values are:
- product - The user has not chosen a product
- variants - The user has chosen a product but the product has at least one
unspecified_variants
remaining - terms - The user has chosen a product and all variants are specified but there is more than one possible prepayment term for this subscription.
- survey - If you have created a survey step the stage will be set to survey.
kvp
kvp
is a dictionary of all arguments specified to the to the subscribe route as key/value pairs. This is used when parsing the subscribe url for the Subscribe Flow contains:
- Chosen products
- Chosen variant values
- Specified metadata from a survey
If the customer is at the url: yourstore.com/subscribe/96_Product1+Name/928_Variant1+Value/tshirtsize_Small
Kvp will contain:
{
96: 'Product1 Name',
928: 'Variant1 Value',
tshirtsize: 'Small'
}
gift
`gift
is a Boolean that is true if the subscribe flow is for a gift order (if the url is of the form yourstore.com/subscribe/gift). False otherwise.
Thank You page
Found in: html/customer/thank_you.html
order
order
is an Order object that represents the completed order after the customer has paid and checkout is complete
Order page
Customer Page Variables
Found in html/customer/order.html
order
order
is an Order object that represents the completed order after the customer has paid and checkout is complete
Login
Found in html/customer/login.html
result
result
is a String that indicates any errors when attempting to log in this user. This is intended to be displayed to the user. Generally this means the user has typo'd their password.
Login
Found in html/customer/login.html
result
result
is a String that indicates any errors when attempting to log in this user. This is intended to be displayed to the user. Generally this means the user has typo'd their password.
Forgot Password
Found in html/customer/forgot_password.html
result
result
is a String that indicates any errors when attempting to reset this user's password. This is intended to be displayed to the user.
Password Reset
Found in html/customer/password_reset.html
result
result
is a String that indicates any errors when attempting to reset this user's password. This is intended to be displayed to the user.
Change Password
Found in html/customer/change_password.html
result
result
is a String that indicates any errors when attempting to change this user's password. This is intended to be displayed to the user.
Edit Subscription
Found in html/customer/edit.html
sub
sub
is a Subscription object which represents the subscription currently being edited by the user. This is chosen based on the parameter in the url such as yourstore.com/customer/edit/subscription/19923 where 11923 is the subscription id.
next_renewal_date
next_renewal_date
is a UTC timestamp in milliseconds that indicates the next date the subscription is scheduled to renew (bill).
new_term (only after an edit)
new_term
is a Term object which contains the new term as chosen by the user after successfully editing a subscription. This is only present after a successful POST to the /customer/edit/subscription route.
Shop Page Variables
Product page
Found in: html/shop/product.html
product
product
is a Product object that is specified by the url parameter, for example _yourshop.com/product/1193_Product+1 will cause Product id 1193 to be loaded.
Listing page
Found in html/shop/listing.html
category
category
is a String which specifies the tag to to filter by. By default this value is "all".
For the url yourstore.com/shop/all the category will be "all"
For the url yourstore.com/shop/dogs the category will be "dogs"
products
products
is a list of Product objects filtered by any specified category
. Only products which are tagged with the category
will be included in this list.
tags
tags
is a list of all tags as an Object across all products;
For example a tags list for a store with two tags on it's products would look like:
[
{
'name': 'For Dogs',
'slug': 'dogs'
},
{
'name': 'For Cats',
'slug': 'cats'
}
]
sort
sort
is a String that specifies the sort order for the listing. It should either be "low" or "high". If not specified the sort order used is "high". This is specified as a query string argument, for example: yourstore.com/shop/all?sort=low.
page
page
is an integer that is the current page number for pagination. By default it will be 1. It can be specified on the url: yourstore.com/shop/all/2