|
6e32320bf56c2b78028d5ff26d7da3c7
|
Hiding default item variantby Bazza - Member - 09:34AM, Oct 28, 2006 |
|
I have been visiting these forums over the last few weeks and they have been a great help, but I need to stop skulking in the shadows and ask for some help directly now. I have made some pretty cosmetic modifications of the Tangerine template. I am no expert in xhtml/css and have no programming background but have sort of figured out the CSS and liquid bits enough to do what I need. If any of the jaded pixels guys are reading this product rocks (just a couple of little things I wish I could do but nothing is perfect right). On thing is stumping me. When you only have one version (i.e. no variants) of a product I would like to hide the default variant radio button on the product.liquid page. I guess this needs to be some sort of condition, and I can see in the template a condition exists to show a sold out flag if a variant is not available. I’ve tried wrapping a statement around this, modifying that one etc. but just can’t get what I want and keep screwing the code. This is the aim – if there is only one variant and it is in stock just the add to cart button should show, if there is only one variant and it is sold out a ‘sold out’ flag to appear, and if there is more than one variant, the radio buttons for each variant and a sold out flag next to them as required. Hope this makes sense. Any help appreciated. |
|
|
You can wrap the variants list in a new if tag. In this example the UL is only shown if there is more then one variant:
---
Tobias Lütke — Last edited 04:47PM, Oct 28, 2006 |
|
|
Thanks for the swift response Tobi. I had a little play with this. Should the initial if statement should have been “>1”. I tried both. However when I implement this I have a problem when I try and add an item which only has one (the default) variant to my cart. I get the following error: Is this because the if statement now excludes the input tag so there is no value being passed if there is only one variant. I’ve also noticed that this appears to exlcude the code to flag an item is sold out if only one variant is available. I have played round with adding an else condition but can’t quite achieve what I am trying to. The whole thing I am trying to avoid is where products with only one variant are listed with a single pre-selected radio button, which I think is slightly odd from a user perspective. Ideallly I still want to indicate to a customer when a product with only one variant is in stock or sold out . Apologies if I am missing something obvious here but its starting to make my head hurt. Has anyone else got around this problem?
|
|
|
Ah right, my fault. You should add ---
Tobias Lütke — Last edited 04:21PM, Oct 29, 2006 |
|
|
Did this work? ---
Tobias Lütke
|
|
|
Sorry offline for a couple of days (back on the day job!) Anyway – it works! Thanks for your help Tobi. Hoping to launch next week.
|
|
|
I must be doing something wrong, but i can’t figure out what:
I’m getting the error: “We were not able to add this item to your shopping cart because no item ID was passed here.â€? Can you help me? ---
Ana Rita
|
|
|
Here is the whole chunk of code I pulled together with the help Tobi provided on my original post.
Hope this helps.
|
|
|
Thank you. I would never (or, being optimistic, would take very long to) get there. ---
Ana Rita
|
|
|
Still on this topic, though I think it’s an issue prior to this alteration: when the client adds a product with a variant to the cart, the product line on the cart has the variant repeated twice. Example: “T-Shirt – M (M)”. Is this happening to you too? ---
Ana Rita
|
|
|
Yes. I solved this by removing the following lines from your cart.liquid:
It seems like the variable “item.title” used on the cart liquid page already sticks the variant name at the end of the product name, and these three lines of code (which output the variant name in brackets) are then not needed. Can anyone confirm this? ---
Folkology – Authentic folk craft and culture from Hungary
|
|
|
Thank you, Kati. In fact, in the mean time, I figured it out myself. Still, I think this is indeed an unnecessary repetition that could be addressed by the developers (I’m presuming this is not caused by the changes made on product.liquid for hiding the default variant). ---
Ana Rita
|
|
|
I’m new to this so I need help with this subject as well. I’m not versed in code so please help me in a way I could do this myself. I’m using the showroom template for my store. I am not adding any products that have variants. I would like to get rid of the variant selection from my products. How do I do this. I have looked at some of the solutions offered by Tobi but when I looked into the product liquid, I did not see the any similar code. I appreciate any help as I am trying to launch my store soon.
|
|
|
hi, hoping someone can help, i am a total newb, i don’t understand where to put the code? i am using the showroom theme. any help is greatly appreciated :)
|
|
|
Hello. I am using the Minimify template for a store I hope to make live soon and I am encountering similar issues when trying to hide the default item variant. I attempted to plug in Bazza’s code posted above for 2-3 hours on Sunday, but I could not figure out exactly where to put it in the lines of code on product.liquid. The closest I could come was when I got the default item variant to vanish, but the price that had been displayed on a second line unrelated to the radio button / drop-down menu also went missing. Any advice would be greatly appreciated, as I don’t want to launch before clearing this up. Thanks! Jon
|
|
|
I did something similar with the add button, hiding it when none of the variants are in stock. Helps reduce the likelihood of people hitting that generic “email the shop owner” error.
|
tobi
Shopify
04:46PM, Oct 28, 2006