How do I implement subscriptions on the product page?

To implement subscriptions on your product page you’ll need to add some code to your themes product.twig file that allows customers to see the available subscription plans and select the one they want.

The code snippet below provides radio options that will allow customers to select a subscription plan (or select that they would like to make a one-time order if the product doesn’t require a subscription).

<div v-if="has_subscription_plans">
   <div v-for="plan in subscription_plans">
       <input type="radio" name="subscription" :id="'subscription-' + plan.id" @click="selectSubscriptionPlan(plan.id)" :checked="has_selected_subscription_plan && selected_subscription_plan.id === plan.id">
       <label :for="'subscription-' + plan.id">
           <span v-text="plan.name + ' ' + plan.price.inc"></span>
           <span v-if="plan.has_saving_price" v-text="'saving: ' + plan.saving_price.inc"></span>
       </label>
   </div>
   <div v-if="!requires_subscription_plan">
       <input type="radio" name="subscription" id="one-time-order" @click="deselectSubscriptionPlan()" :checked="!has_selected_subscription_plan">
       <label for="one-time-order">
           One-time order
       </label>
   </div>
</div>

Articles in this section

Was this article helpful?
0 out of 0 found this helpful