How to prevent customers access to a collection or product in Shopify without app
If for some reason you do not want your customers to access a certain collection or product on your Shopify store but you don’t want to hide them. This article will guide you how to prevent customers from accessing a collection or product page without a Shopify app.
- From your Shopify admin, go to Online Store > Themes.
- Find the theme you want to edit, and then click Actions > Edit code.
- In the Templates directory, click Add a new template.
- In the dialog appear, you choose Collection or Product for the select box dropdown and fill prevent for the next input field.
- Removing all exist code, then inserting below code to this file1{% layout none %}<script>window.location.replace("/");</script>
- Click Save.
Now, you need to open the collection or product you want to prevent access and set the default template for them.
You are done and you can check it out.
Now, if someone accesses this collection or product page, the browser will automatically redirect them to the homepage.
I hope this article is helpful for you.