i want to hide swatches of configurable products which has 0 quantity and i want to use the best approach possible is there any?
how to do that any idea?
Check Show out of stock product
setting under Stores -> Configuration -> Catalog -> Inventory
Set Show out of stock product
to No
.
And then clear System Cache.
See https://docs.magento.com/user-guide/configuration/catalog/inventory.html for more details.