I know, there have been some disussions about this topic in the past years. It seems that there have been some solutions, but none of them still work or do work for me.
What I need is actually fairly easy -> just hide variants that have stock 0, are sold out
There once was a code by shopify
But that code doesn't work on themes that have are sectioned, which all of them are now.
Please, help :D
I understand your issue where you want to hide variants from your store that are out of stock so it will not create a bad user experience for customers.
I recently came across an app, AutoHide Soldout Products which worked for me to hide out of stock products & variants like size, colour. Once products are back in stock, it will be unhidden from the store automatically.
They can help you to do any customization requests you have. Download the app (https://apps.shopify.com/autohide-soldout-products) & contact their support team, they are really fast!