Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

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

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
7 1 2

Hi,

 

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