There comes a time in every Shopify store’s journey when you need to hide products from your customers. If a product is sold out, or you want to hide it from your entire customer base for whatever reason, that’s easy to do on Shopify. But what about hiding a specific product from a specific group of customers?
Let’s take a look at the following scenario. You have a group of customers who have subscribed to regular purchases of your product. You want to reward them for their loyalty by making a product available exclusively to them. Using the following code, this becomes possible!
You can hide products using whatever criteria you want, like geographical location, age, etc.
We used the Debut theme for this example, but this method can be used in other Shopify themes as well.
IMPORTANT: Before continuing, we recommend creating a copy of the theme and working using the copy.
Create a copy of the theme in the Online Store section. In Themes, click Actions and select Duplicate. Wait for the created theme to finish loading.
In your newly created copy of the theme, click Actions and then Edit Code.
Add a new product template called hidden. This will create the product.hidden.liquid file.
At the end of the file, close with the following code and save it. You can change the /collections text to the URL of the page you want to redirect to when an unauthorized user tries to open a product that is intended for the specific customer group.
In the product that you want to hide, change to the new product template and save the changes.
NOTE: if the new template doesn’t appear in the templates list, you’ll need to create it in the current live theme without adding the code.
To test, preview the new theme and try to open the product without a customer session, this will redirect you to the collections page.
To open the hidden product, add the ws-access tag to the customer account, log in to the store and try to open the product.
To hide more products, just change the product template and start tagging customers! Now, only customers who are tagged will be able to see the products that are intended for the,.
You can apply the same implementation to other templates or create more product templates while using different customers tags. You can also improve the validation reading product properties such as price, stock, etc.
Are you ready to start hiding products? While this is a relatively simply customization, if you’re not comfortable working with code we’d be happy to help you implement this awesome feature. Get in touch with us and we can make your customization dreams a reality!