{"_id":"58112e73ded0340f0085d06c","version":{"_id":"58112e71ded0340f0085d02a","project":"551e85be610f400d00837db7","__v":4,"createdAt":"2016-10-26T22:30:09.862Z","releaseDate":"2016-10-26T22:30:09.862Z","categories":["58112e72ded0340f0085d02b","58112e72ded0340f0085d02c","58112e72ded0340f0085d02d","58112e72ded0340f0085d02e","58112e72ded0340f0085d02f","58112e72ded0340f0085d030","58112e72ded0340f0085d031","58112e72ded0340f0085d032","58112e72ded0340f0085d033","58112e72ded0340f0085d034","581137cc604d3c230048b7e4","58dc367221742d0f00a73f98","590768e54669da0f00db5c0b"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"new designer","version_clean":"2.0.0","version":"2.0"},"category":{"_id":"58112e72ded0340f0085d02c","project":"551e85be610f400d00837db7","__v":0,"version":"58112e71ded0340f0085d02a","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-04-07T18:58:09.521Z","from_sync":false,"order":2,"slug":"theme-logic","title":"Theme Logic & Components"},"parentDoc":null,"user":"551e85707ca3030d00be0c07","__v":0,"project":"551e85be610f400d00837db7","updates":["55916d554a0d680d001b8277"],"next":{"pages":[],"description":""},"createdAt":"2015-04-08T10:45:09.265Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"Page variables are available to the theme at run time to be referenced via Jinja.\n\nFor example a page variable named ``store`` with an attribute of name can be referenced like this:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{{ store.name }}\",\n      \"language\": \"jinja2\"\n    }\n  ]\n}\n[/block]\nMany 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.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Global Page Variables\"\n}\n[/block]\nThese variables are accessible from every page on your storefront.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Variable Name\",\n    \"h-1\": \"Type\",\n    \"2-0\": \"``store``\",\n    \"2-1\": \"[``Store``](store-object-types#store)\",\n    \"3-0\": \"``guest``\",\n    \"3-1\": \"Boolean\",\n    \"3-2\": \"True if the visitor is anonymous, False if logged in.\",\n    \"h-2\": \"Note\",\n    \"4-0\": \"``customer``\",\n    \"4-1\": \"[``Customer``](store-object-types#customer)\",\n    \"4-2\": \"Only present when the customer is logged in (``guest`` is False).\",\n    \"5-0\": \"``custom_domain``\",\n    \"5-1\": \"String\",\n    \"5-2\": \"The custom domain set up for your storefront (such as \\\"www.mystore.com\\\").\",\n    \"6-0\": \"``cratejoy_domain``\",\n    \"6-1\": \"String\",\n    \"6-2\": \"The cratejoy subdomain for your storefront (such as yourstore.cratejoy.com).\",\n    \"7-0\": \"``test_mode``\",\n    \"7-1\": \"Boolean\",\n    \"7-2\": \"True if the store is in test mode, False otherwise.\",\n    \"8-0\": \"``settings``\",\n    \"8-1\": \"Object\",\n    \"8-2\": \"The theme settings for the current installed theme.\",\n    \"9-0\": \"``args``\",\n    \"9-1\": \"dict\",\n    \"9-2\": \"Any arguments that were specified on this request via the query string (such as ?product_id=2323).\",\n    \"0-0\": \"``slug``\",\n    \"0-1\": \"String\",\n    \"0-2\": \"First part of the path for current page (so \\\"index\\\" for index, \\\"subscribe\\\" for \\\"/subscribe/\\\", \\\"customer\\\" for \\\"/customer/thank_you\\\")\",\n    \"1-0\": \"``path``\",\n    \"1-1\": \"String\",\n    \"1-2\": \"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\\\"\",\n    \"2-2\": \"The current storefront's [``Store``](store-object-types#store) object.\"\n  },\n  \"cols\": 3,\n  \"rows\": 10\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Subscribe Page Variables\"\n}\n[/block]\nCertain pages of your storefront automatically have additional special variables made available to them.\n\n# Subscribe\n\nFound in ``html/subscribe.html``\n\nThe 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](doc:subscribe-flow).\n\n## steps\n\n``steps`` is an array of tuples which serves to tell the subscribe page where in the signup process the user currently is.\n\nIf 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.\n\nsteps contains:\n```\n[\n    ('product', None),\n    ('variant', VariantType1),\n    ('variant', VariantType2),\n    ('term', None)\n]\n```\n\nIf 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.\n\n```\n[\n    ('variant', VariantType1),\n    ('term', None)\n]\n```\n\n*If the order is a gift order the variant steps are omitted as the recipient chooses the variants on a gift order*\n\n## cur_step\n\n``cur_step`` is an integer that represents the customer's progress through the [Subscribe Flow](doc: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.\n\n## product\n\n``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.\n\n## instance\n\n``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.\n\n## chosen_values\n\n``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](doc:subscribe-flow) documentation.\n\n## possible_values\n\n``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.\n\n## unspecified_variants\n\n``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.\n\n## stage\n\n``stage`` is a String that indicates the current stage in the [Subscribe Flow](doc:subscribe-flow). \n\nIt's possible values are:\n* product - The user has not chosen a product\n* variants - The user has chosen a product but the product has at least one ``unspecified_variants`` remaining\n* terms - The user has chosen a product and all variants are specified but there is more than one possible prepayment term for this subscription.\n* survey - If you have created a survey step the stage will be set to survey.\n\n## kvp\n\n``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](doc:subscribe-flow) contains: \n\n* Chosen products\n* Chosen variant values\n* Specified metadata from a survey\n\nIf the customer is at the url: _yourstore.com/subscribe/96_Product1+Name/928_Variant1+Value/tshirtsize_Small_\n\nKvp will contain:\n```\n{\n    96: 'Product1 Name',\n    928: 'Variant1 Value',\n    tshirtsize: 'Small'\n}\n```\n\n## gift\n\n```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.\n\n# Thank You page\n\nFound in: ``html/customer/thank_you.html``\n\n## order\n\n``order`` is an Order object that represents the completed order after the customer has paid and checkout is complete\n\n# Order page\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Customer Page Variables\"\n}\n[/block]\nFound in ``html/customer/order.html``\n\n## order\n\n``order`` is an Order object that represents the completed order after the customer has paid and checkout is complete\n\n# Login\n\nFound in ``html/customer/login.html``\n\n## result\n\n``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.\n\n# Login\n\nFound in ``html/customer/login.html``\n\n## result\n\n``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.\n\n# Forgot Password\n\nFound in ``html/customer/forgot_password.html``\n\n## result\n\n``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.\n\n# Password Reset\n\nFound in ``html/customer/password_reset.html``\n\n## result\n\n``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.\n\n# Change Password\n\nFound in ``html/customer/change_password.html``\n\n## result\n\n``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.\n\n# Edit Subscription\n\nFound in ``html/customer/edit.html``\n\n## sub\n\n``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.\n\n## next_renewal_date\n\n``next_renewal_date`` is a UTC timestamp in milliseconds that indicates the next date the subscription is scheduled to renew (bill).\n\n## new_term (only after an edit)\n\n``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.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Shop Page Variables\"\n}\n[/block]\n# Product page\n\nFound in: ``html/shop/product.html``\n\n## product\n\n``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.\n\n# Listing page\n\nFound in ``html/shop/listing.html``\n\n## category\n\n``category`` is a String which specifies the tag to to filter by. By default this value is \"all\".\n\nFor the url _yourstore.com/shop/all_ the category will be \"all\"\n\nFor the url _yourstore.com/shop/dogs_ the category will be \"dogs\"\n\n## products\n\n``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.\n\n## tags\n\n``tags`` is a list of all tags as an Object across all products;\n\nFor example a tags list for a store with two tags on it's products would look like:\n\n```\n[\n    {\n        'name': 'For Dogs',\n        'slug': 'dogs'\n    },\n    {\n        'name': 'For Cats',\n        'slug': 'cats'\n    }\n]\n```\n\n## sort\n\n``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_.\n\n## page\n\n``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_","excerpt":"","slug":"page-variables","type":"basic","title":"Page Variables"}
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: [block:code] { "codes": [ { "code": "{{ store.name }}", "language": "jinja2" } ] } [/block] 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. [block:api-header] { "type": "basic", "title": "Global Page Variables" } [/block] These variables are accessible from every page on your storefront. [block:parameters] { "data": { "h-0": "Variable Name", "h-1": "Type", "2-0": "``store``", "2-1": "[``Store``](store-object-types#store)", "3-0": "``guest``", "3-1": "Boolean", "3-2": "True if the visitor is anonymous, False if logged in.", "h-2": "Note", "4-0": "``customer``", "4-1": "[``Customer``](store-object-types#customer)", "4-2": "Only present when the customer is logged in (``guest`` is False).", "5-0": "``custom_domain``", "5-1": "String", "5-2": "The custom domain set up for your storefront (such as \"www.mystore.com\").", "6-0": "``cratejoy_domain``", "6-1": "String", "6-2": "The cratejoy subdomain for your storefront (such as yourstore.cratejoy.com).", "7-0": "``test_mode``", "7-1": "Boolean", "7-2": "True if the store is in test mode, False otherwise.", "8-0": "``settings``", "8-1": "Object", "8-2": "The theme settings for the current installed theme.", "9-0": "``args``", "9-1": "dict", "9-2": "Any arguments that were specified on this request via the query string (such as ?product_id=2323).", "0-0": "``slug``", "0-1": "String", "0-2": "First part of the path for current page (so \"index\" for index, \"subscribe\" for \"/subscribe/\", \"customer\" for \"/customer/thank_you\")", "1-0": "``path``", "1-1": "String", "1-2": "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\"", "2-2": "The current storefront's [``Store``](store-object-types#store) object." }, "cols": 3, "rows": 10 } [/block] [block:api-header] { "type": "basic", "title": "Subscribe Page Variables" } [/block] 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](doc:subscribe-flow). ## 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](doc: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](doc: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](doc: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](doc: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 [block:api-header] { "type": "basic", "title": "Customer Page Variables" } [/block] 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. [block:api-header] { "type": "basic", "title": "Shop Page Variables" } [/block] # 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_