In Spring of 2016, we introduced a new subscribe flow builder, along with a survey builder. The below information reflects the traditional subscribe flow.
The Subscribe Flow handles your subscribersâ selection of a subscription product, any variants, and the term of their subscription. Cratejoyâs themes are set up to handle an arbitrary number of products and variants, and the most widely used combinations of term length and number. To handle this, we have many convenient filters and methods to handle subscribersâ product, variant and term choices.
Subscribersâ selections are handled by building a subscribe URL that corresponds to each decision point along the Subscribe Flow. The URL path consists of multiple ID-Value choice parts, where the IDs are unique Cratejoy IDs, and the Values are your product or variant names . These URLâs are provided by the product_subscribe_url
filter.
EXAMPLE SUBSCRIBE FLOW
Suppose you had 2 products:
- âDeluxe Boxâ
- âRegular Boxâ
Each product has 2 product variants:
- Flavor is âSavoryâ or âSweetâ
- Gluten Restriction is âGlutenâ or âGluten Freeâ.
The terms available are:
- âMonth-to-Monthâ
- â3 Month Prepayâ
- â6 Month Prepayâ
Here is how an example checkout may take place on this store:
- Subscriber is on yourstore.com/subscribe
- Subscriber is shown a list of products
- Subscriber chooses the âDeluxe Boxâ product
- Subscriber is sent to yourstore.com/subscribe/1111_Deluxe+Box
- The Cratejoy platform knows there are 2 product variant types available for this product, so it asks which of the Flavor variant typeâs values the subscriber wants.
- Subscriber chooses the âSavoryâ variant value
- Subscriber is sent to yourstore.com/subscribe/1111_Deluxe+Box/2222_Savory
- Cratejoy platform knows there is a second product variant type available for this product, so it asks which of the GlutenRestriction variant typeâs values the subscriber wants
- Subscriber chooses the âGluten Freeâ variant value
- Subscriber is sent to yourstore.com/subscribe/1111_Deluxe+Box/2222_Savory/3333_Gluten+Free
- Cratejoy platform knows that only one product instance exists with this combination of variants, so it asks which enabled term the subscriber wants
- Subscriber chooses the â6 Month Prepayâ term
- Subscriber is sent to yourstore.com/subscribe/1111_Deluxe+Box/2222_Savory/3333_Gluten+Free/4444_6+Month+Prepay
- Since that selects a unique product instance and a term, Cratejoy will automatically redirect them to the secure checkout page with the subscriberâs selections in the cart.
- Subscriber is sent to yourstore.com/checkout to finalize the purchase.
It's important to realize that if on any step there's only one valid option, the Cratejoy platform will automatically select that option and forward the subscriber on to the next step. For example, if you have a single product, which has multiple variants, hitting yourstore.com/subscribe will send them directly to the variant selection for that product- -that is, yourstore.com/subscribe/1111_Deluxe+Box. If you have a single product with no variants and a single payment term, yourstore.com/subscribe will take them straight to checkout.
In addition to cases where there is only one product/variant/term, you might have a situation where you have multiple products, but only one is valid for their current state, such as if the subscriber used the yourstore.com/ac/COUPON_CODE route to add a coupon that only applies to a single product.
SUBSCRIBE FLOW CODE
The base template for handling the subscribe flow is subscribe.html
. It handles determining what stage of the subscribe flow the subscriber is currently in, iterating over the options available for the current stage, then including the template for the current subscribe flow grid item. In a few themes, the individual product, term, and variant item code are in the html/subscribe_flow/ directory. The Cratejoy platform determines which stage the subscriber is on automatically based on the arguments to the subscribe route.
The stages of the subscribe flow are:
1. PRODUCT CHOICE
The subscribe_flow.html/product_grid_item.html
typically contains the code that displays a single product option. It contains the formatting, image layouts, product name and description, as well as the subscribe stage link for selecting the product. The URL for the selection link for a product is produced by the product_subscribe_url
filter
<a href="{{ product | product_subscribe_url(gift=gift) }}">
2. VARIANT CHOICE
At the Variant Choice stage, the subscriber has selected a product, and if the product has 1 or more variant, the Cratejoy platform asks for variant choices until a single product instance has been selected.
The subscribe_flow/variant_grid_item.html
file typically contains the code that displays a single variant option. Its format is similar to the subscribe_flow/product_grid_item.html templates, except for a few variant specific changes, such as the format for the selection link URL for each variant value, which is
<a href="{{ product | product_subscribe_url(chosen_values, value, gift=gift) }}">
3. TERM CHOICE
At the Term Choice stage, the subscriber has selected a unique product instance, and if the instance has 1 or more enabled term choices, the Cratejoy platform asks which term the subscriber wants.
The subscribe_flow/term_grid_item.html contains the code that displays a single term option. Its format is similar to the subscribe_flow/product_grid_item.html and subscribe_flow/variant_grid_item.html templates. The format for the term selection link URL is:
<a href="{{ product | product_subscribe_url(chosen_values, term_price.term, gift=gift) }}">