How to force user login/signup before adding a product to cart on your Shopify store?
You are building an store where you want to force my users to login when they try to add a product to cart. It’s easy.
Find the add to cart button, you should be able to find this within the product-form.liquid, product.liquid template. May be, it will generally look like this:
1 | <input type="submit" name="add" class="btn" id="add-to-cart" value="Add to Cart"> |
Edit as follow:
1 2 3 4 5 | {% if customer %} <input type="submit" name="add" class="btn" id="add-to-cart" value="Add to Cart"> {% else %} <p>Please <a href="/account/login">login</a> to buy this product!</p> {% endif %} |
Finally, you may edit style with CSS to look better.