Liquid Code that Targets Products that Don't Track Inventory?

Gregeko
Shopify Partner
9 1 1

Hello,

 

I'm working on a theme and the product page is currently showing Out of Stock on products that are set to Not Track Inventory. I've located the code that handles this but not sure how to create an if statement for products that don't track inventory.

 

The code says to show the Add to Cart button if the inventory is greater than 0, otherwise show the Out of Stock prompt... but this doesn't account for products that don't track inventory.

 

How can I target products that don't track inventory? Any help would be greatly appreciated!

 

Here is the code...

  if (parseInt(this_qty) > 0 || this_policy == "continue"){
    $(".atc-trigger.primary").removeClass("disabled")
    $(".stock-status .available").show()
    $(".stock-status .unavailable").hide()
  }
  else {
    $(".atc-trigger.primary").addClass("disabled")
    $(".stock-status .available").hide()
    $(".stock-status .unavailable").show()
  }

 

I'm not sure if this is the right place to ask, if not can you please point me in the right direction?

Reply 1 (1)

betelgeus
Shopify Partner
6 1 2

Hi,

 

You can use `product.available` or `variant.available`