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.
![](https://scontent-lga3-2.xx.fbcdn.net/v/t1.6435-9/120701542_3725838864128119_3179787695451382452_n.png?_nc_cat=104&ccb=1-7&_nc_sid=d9b88e&_nc_ohc=6y4vqZt1lNsQ7kNvgFHgqga&_nc_ht=scontent-lga3-2.xx&edm=AMAeTUEEAAAA&oh=00_AYD5ycqsY8eIx8pIneVSSlnM3h8Fz4o0oS8Q3QeJQuhBqg&oe=66C35B36)
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.