Hide subscription widget from wholesale customers
How to Hide the Subscription Widget for Customers Tagged as “Wholesale”
As a Shopify store merchant, you're able to sell to both retail and wholesale customers, however a problem that merchants encounter with using this with subscriptions, is when Wholesale customers enjoy wholesale discounts along with subscription discounts. For that reason, the solution with Seal Subscriptions, is to hide the subscription widget from customers who have a “wholesale” customer tag. This guide will walk you through the steps to hide the subscription widget for customers tagged as "wholesale" specifically in the Dawn theme
Step 1: Access Your Theme Editor
- Log in to your Shopify admin.
- Navigate to Online Store > Themes.
- Find the Dawn theme and click Actions > Edit code.
Step 2: Identify where to add the code
Locate the main-product.liquid file, which is where the subscription widget will be rendered. That is the main product page in your Shopify store.
You will need to look for the form element that starts with the text {% form 'product' and add a new line right below it, which is where you will be adding the subscription widget
Step 3: Add Conditional Logic
Insert a conditional statement to hide the subscription widget for customers tagged as "wholesale." Use the following Liquid code snippet:
{% if customer.tags contains 'wholesale' %}
<!-- Subscription widget hidden for wholesale customers -->
{% else %}
<div class="sealsubs-target-element" data-product="{{ product | json | escape }}" data-handle="{{ product.handle }}"></div>
{% endif %}
And then save your changes in the theme code editor
Step 4: Prevent the widget from rendering automatically
This step is required due to the fact that our Seal Subscriptions script can automatically include the subscription widget on the product page. This means that we will need to enable the feature to only display the widget on the page if there is a subscription widget code snippet, which is what we added:
- Go to Seal Subscriptions
- Go to Settings
- Click General settings
- Then Advanced
- Check the box before the “Render widgets only if the HTML snippet is present in the Liquid file” option
- Save the settings
Step 5: Test the Changes
- Open your store as a logged-in customer with the "wholesale" tag and verify that the subscription widget is hidden.
- Test with a customer account without the "wholesale" tag to ensure the widget appears as expected.
Step 6: Publish Your Theme
Once you’ve confirmed that the changes work as intended, publish your theme to make the changes live for your customers.
Additional Notes
- Ensure the tag "wholesale" is correctly applied to relevant customer accounts.
- Backup your theme files before making any changes to prevent accidental loss of code.
- For manual installation, follow the steps to add the widget as described in the Seal Subscriptions manual installation guide, ensuring it is properly wrapped within the form element.
By following these steps, you can successfully hide the subscription widget for customers tagged as "wholesale." This ensures a seamless experience tailored to your business needs.
If you experience any issues with this method, don't hesitate to contact our support team at support@sealsubscriptions.com!