Displaying subscriptions on your website
The new Subscriptions app requires code changes to your website's theme. Existing theme code for the earlier Subscriptions app uses subscription intervals and does not submit the plan details required by the new system.
Update product page templates
Update product page templates
Edit the theme template that renders the product purchase form. In many themes this is views/partials/product_form.twig, but the file can differ in a customised theme. Replace the earlier subscription interval selector with a selector for the new plans.
The following Twig values are available for this work:
| Twig value | Use |
|---|---|
product.has_subscription_plans |
Check whether the product has plans in the new system |
product.subscription_plans |
Get plans assigned to the base product SKU |
product.variations |
Get variations; each variation has its own subscription_plans list |
product.one_off_purchasing |
Check whether to offer a one-off purchase option |
plan.id and plan.version |
Identify the selected plan in the add-to-basket form |
plan.name, plan.interval and plan.interval_count |
Describe the plan to the visitor |
plan.cycle_limit, plan.trial_days, plan.price_modifier_type and plan.price_modifier_value |
Describe any limit, trial or pricing rule |
Render only the plans assigned to the selected base SKU or product variation. When the visitor changes a variation, update the plan choices to match that variation and clear any plan that is no longer available. Offer a one-off choice only when product.one_off_purchasing is true.
The earlier product.subscription and product.subscription_intervals values belong to the old system. They do not provide the new plan choices after activation.
Update the add-to-basket form
Update the add-to-basket form
When the visitor selects a plan, the product form must submit both of these fields with the add-to-basket request:
| Form field | Value |
|---|---|
subscription_plan_id |
The selected plan's id |
subscription_plan_version |
The selected plan's version |
If the visitor selects a one-off purchase, submit one_off_purchase with a true value and clear both plan fields. If the visitor selects a plan, clear the one-off value. Update these fields whenever the plan or variation selection changes.
ShopWired checks the submitted plan ID and version against the selected product's exact SKU. It rejects a plan that is no longer available or has changed version. Do not submit the earlier subscription_interval value as a substitute for a plan.
Update basket and order templates
Update basket and order templates
Use the basket item's subscription_plan value to show the selected plan in the basket. Use the order product's subscription_plan value to show it in order displays. These values provide the plan name, interval, trial and other recorded plan details.
Review any theme code that displays subscription_interval on basket items or ordered products. That value describes the earlier subscription system and does not identify a new plan.
Customer subscription management pages
Customer subscription management pages
The new customer subscription management pages are outside your ShopWired account's normal theme. You do not need to code these pages into your theme, and they cannot currently be customised. Theme customisation for these pages is planned for a future update.
The existing account_subscriptions.twig and account_subscription.twig templates belong to the earlier subscription system. Do not use them to display contracts from the new app.
Check the theme before activation
Check the theme before activation
- Confirm that the active theme contains the new product plan selector and add-to-basket form fields
- Confirm that variation changes update the available plans and selected plan version
- Confirm that the basket and order templates display the selected plan
- Arrange a test of the new plan flow on an account using the new subscription system
The new plan Twig values are populated only after an account uses the new subscription system. A preview of a business that has not activated it cannot prove that the selector works with real plan data. Contact theme support for help with coding or testing these changes.