Solved

Triggering Back in Stock before inventory reaches zero

  • 17 November 2020
  • 3 replies
  • 147 views

Badge

Howdy folks,

We’re implementing back in stock for a client on Shopify and of course it works perfectly for them.  When stock equals zero the sold out button appears and the BIS button is displayed.  However, our client now wants to show the back in stock button when their inventory is at 3 or less.  This allows them to avoid over selling and keeps them ahead of their stock levels. 

 

My approach to implementing this was to physically implement the BIS button in the product template when inventory <= 3:

{% if stock_available <= 3  %} 
<a class="klaviyo-bis-trigger" href="#">Notify Me When Available</a>
{% endif %}

 

Of course, this does display the BIS button but the actual triggering of various JavaScript elements does not occur as Klaviyo.js is listening out for stock levels to equal 0 before working it’s magic.  Does anyone know how I can override the stock level threshold so Klaviyo’s back in stock functionality kicks in when stock is less than or equal to 3?

 

Great so see the forum getting so much action already!

 

Loughlin.

icon

Best answer by milkbottlelough 17 November 2020, 23:47

Hey, I got this working - for those interested I overrode the getProductJSON function in onsite.js to report a false value for the inventory (i.e. 0 when it was 2).  Works :)

View original

3 replies

Badge

Hey, I got this working - for those interested I overrode the getProductJSON function in onsite.js to report a false value for the inventory (i.e. 0 when it was 2).  Works :)

Userlevel 6
Badge +5

Hi @milkbottlelough - thanks for asking your first question AND sharing your first answer all in one post! Glad to hear that you were able to override and get this working, and thanks for filling the rest of us in.

Badge

Hey there, since posting this approach we have noticed it has been problematic and I would not recommend messing around with the onsite.js JavaScript file that Klaviyo injects into your page.

We’ve noticed issues with how BIS works and how the button operates when “tricking” Klaviyo into thinking the item is sold out when in fact there is still stock available.

 

Maybe someday Klaviyo will include a threshold setting to determine when stock is approaching 0 and show the BIS button then but alas this is currently not an option (as of May 2021 anyway).

Reply