Hey there!
We have a wholesale and retail store that needs to hide the ability for someone who is not a verified user to access or create a cart (we are using the Dawn theme). I have used an if statement in order to hide the “add to cart” option within the product page. However, I cannot find the code to put this if statement in to hide the add to cart button on featured collection and standard collection pages. Does anybody know where this is, or of another way to hide the button when users are not logged in?
Many thanks!
Hello,
Can you please share the store URL, and the if statement which you have used. I can help you then.
Thank you!
Sure the url is:
The if statement was a simple:
{% if customer %}
Code where button code is displayed.
{% endif %}
Yes, please try this.
{% if customer.id == null %}
Add to cart
{% endif %}
Ok I will, but part of my problem is that I do not know where to put this code. I need this to affect the collect pages as well as featured collections.
I can quickly do it for you, I would need a quick access though. Contact me if you want.
Thank you.
If you don’t mind, can you just give me an idea of where this section of code is? I am trying to learn, and would appreciate simply finding the block of code that is responsible for displaying the add to cart feature, and wrapping it in the statement. Thanks
Hi @SeanConnors ,
This is Victor from PageFly - Shopify Page Builder App.
If you want to use this code, you have to add it inside your collection template file.
Step 1: Online Stores > More action > edit code > find collection (they will return a list of collection files)
Step 2: Please select each file and search it (Hit Ctrl F or CMD F to find “ btn btn-globo globo–add-to-cart globo-ajax-form-cart">Add to cart “)
Step 3: Paste the following code right into the place
{% if customer.id == null %}
{% endif %}
That means you will place the if tag once you found it.
Hope this can help you solve the issue.
Best regards,
Victor | PageFly
I am using the template Dawn, and I can’t find that bit of code. I searched for in any .liquid file for collections:
btn btn-globo globo–add-to-cart globo-ajax-form-cart
Any idea which file in dawn it would be under?
Hi @SeanConnors ,
The thing is the button and product template has been modified by an app. Is that possible for grant me access to collaborator? Or you can download your theme file and send it to me? That will be quicker.
Turns out the issue was that the add to cart button was being added by a plugin, so when I edited the theme code nothing was happening. Was able to get it working when I disabled the plugin and used the base Shopify add to cart button. Having a few other issues, but this is solved, thanks for your help!