In this product, the gold variant is sold out, and the silver variant is in stock.
I’m trying to write a line of code that adds a ‘strikethrough’ to the variant title so the customer does not have to click it to find out that it is out of stock.
The code presented which produces the variant title is as follows:
{{ value }} is the variant title, so if I add a either side of it the title strikes through.
I tried to write a line of code that checks the variants stock and to subsequently strike through sold out variants, but for some reason I could only get it to strike both variants, not just the gold one.
Could someone assist please? She is using the all new Dawn theme for reference.
It only solution with one variant, if you have more than 1 variant, you need to customize a lot, including JS, so I can’t guide you in detail. And it will be difficult for someone else to help you only with the instructions.
I’ve added this code and it works great! The only issue is I’m using a back-in-stock plugin, and it relies on the variant in the URL. When I click the out-of-stock variants, it doesn’t reflect in the URL.
Is it possible to change the code so they still have the strikethrough, but can still be clicked so the variant in the URL changes?
Are there any updates to this code? I tried the previous code but it ended up creating a strikethrough for all -both variants and size options. However, the available sizes are still clickable despite it being crossed out (see screenshot below). So basically the concept is working, just need the strikethrough and light coloring to only be on sold out sizes.
Great work Jose. I have found a bug with the code though. The add to cart button is grayed out (even on instock products) on the product page. You have to first switch between the variant to re-enable it.
Well done @josephbona , I replaced the js code for VariantRadios in global.js and added the css code you provide for section-main-product.css (even added !important to the code), and unfortunately didn’t achieve the same result, maybe I missed something