Setting a Default Selling Plan for Subscription Products in Shopify

This guide walks you through setting a default selling plan for products. This ensures customers see the first available plan as the default option on your product page, creating a smoother experience even before additional app scripts load.

Setting a Default Selling Plan for Subscription Products in Shopify

Description: This guide will help you set a default selling plan for subscription-only products, so customers will see the first available plan as pre-selected on the product page, even before additional app scripts load.

Steps to Set a Default Selling Plan

Follow these steps to set a default selling plan for your subscription products:

Step 1: Access Your Theme’s Code

In your Shopify admin dashboard, go to Online Store > Themes. Find the theme you’re currently using, then click Actions > Edit code.

Step 2: Locate Your Product Template File

In the left sidebar, open the Sections or Templates folder. Look for a file named product.liquid or product-template.liquid (the exact name depends on your theme). Click this file to open it.

Step 3: Add the Default Selling Plan Code

Inside the product template file, locate the form section where the product options are displayed. This is usually within <form>...</form> tags. Add the following code inside the form to set the first selling plan as the default:

<!-- Automatically select the first selling plan if the product only has subscription options -->
{% if product.requires_selling_plan %}
    <input type="hidden" name="selling_plan" value="{{ product.selling_plan_groups.first.selling_plans.first.id }}">
{% endif %}
    

Example of Code Placement

Here’s an example of how this code might look within a typical product form section. Place the new code within the <form> tags:

<form action="/cart/add" method="post" enctype="multipart/form-data">
    <!-- Existing product form elements here -->

    <!-- Automatically select the first selling plan if the product only has subscription options -->
    {% if product.requires_selling_plan %}
        <input type="hidden" name="selling_plan" value="{{ product.selling_plan_groups.first.selling_plans.first.id }}">
    {% endif %}

    <button type="submit">Add to Cart</button>
</form>
    

This code checks if the product requires a subscription plan and, if so, sets the first available plan as the default. Make sure to place it before the submit button.

Step 4: Save and Preview

  1. Click the Save button at the top of the code editor.
  2. Preview a product with subscription-only options to ensure the default selling plan is pre-selected.

Troubleshooting Tips

If the default plan isn’t selected, check the following:

For more details, refer to Shopify’s developer documentation on selling plans.

Need help? Contact our support team!

Back to Help Center