Change out of stock message based on variant selection

On a certain product type or collection, if you click on a variant that has 0 for inventory, I want to show a custom button vs “coming soon” which is the default in the language file.

I’ve tried

if collection.handle == 'example' ... or if product.type == "ABC"

But I’m guessing when you click on a variant it does not do any checks for that, only on page load? So do i need to find the code that is executed when clicking a variant option - if, so where would that be?

Any help would be appreciated!

Where code is located varies wildly between themes leaving that detail out complicates discussing theme development.

Generally it’s in global.js for Dawn based themes, or script.js, theme.js etc etc

Some may have it more granular and be in a variant.js component file, or within the product-forms sections/snippet code.

thanks @PaulNewton - I was able to find it, but there is way to much JS for variants for me to get a handle on what’s going :slightly_smiling_face: - wondering if there is a better way?