I wanted to disable sold out product variants so I did some research and came across a recommended code from the following link (https://help.shopify.com/en/manual/online-store/themes/os/customize/hide-sold-out-variants ) . I pasted the code at the bottom of “ theme.js" under “Assets” as instructed but it did not do what it was supposed to do AND it messed up some other things:
If an item is available in one variant and sold out in another, it allows people to add the sold out variant to cart. When you get to the cart the available variant is there instead of the sold out variant that was chosen.
On Desktop view I can no longer choose my drop down menu. I tried deleting it and adding it back but it still won’t work.
On mobile view I can’t click the menu at all.
I’m not a coder but I’m very determined so when I made the change I was sure to follow instructions and I notated which line I added the code to thinking that I could always delete it if it didn’t work. Unfortunately, my website is still not back to what it was after deleting the code.
Please help me revert my website to how it was a couple of hours ago and also if you know how to disable sold out variants that would help to.
Luna here from Shopify. Thank you for posting your question here on our Community forums and sharing your experience. I’m sorry to hear that this didn’t work as expected, I’m happy to help.
In order to revert your theme back, I recommend following this guide: Roll back to an older version of your theme. This will allow you to undo the coding changes you made easily. I also recommend that going forward, you duplicate your theme before making any changes. You can then make the changes to your duplicated theme, rather than the live theme, to test them first.
Although I cannot help with the code changes specifically, I can make some suggestions to achieve this. Based on the information you’ve shared, I suggest checking out some apps! I’ve discovered a couple that could help you, such as:
Out-of-Stock Police: This app allows you to easily organize or hide out-of-stock products. You can also turn on notifications that will alert you when a product is getting low in stock. This app has a free plan available.
Push Down & Hide Out of Stock Products: With this app, you can move out-of-stock products to the bottom, hide out-of-stock products, unhide back-in-stock products easily. There is no coding required and a free plan is offered.
To browse other options, check our Shopify app store here. I also recommend reading the reviews, to determine if the app is suitable for your needs. As well, most apps offer a free trial so that you can test it out before committing. If you decide to not use the app, just ensure that you uninstall it before the trial ends to avoid getting charged. You can learn more about this process in our help document on Working with apps.
Otherwise, you could consider hiring a Shopify Expert to help you with the coding customizations.
May I ask why you’re hoping to hide out-of-stock products? I’d love to hear more about your business! Please let me know if you have any questions, I’m happy to help.