Change out of stock message based on variant selection

Change out of stock message based on variant selection

steakNshake
Shopify Partner
4 0 2

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!

 

Screen Shot 2022-10-26 at 3.43.42 PM.png

Replies 2 (2)

PaulNewton
Shopify Partner
7746 679 1614

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.

 

 

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


steakNshake
Shopify Partner
4 0 2

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 🙂 - wondering if there is a better way?