Verify Variant.Inventory_quantity when selecting another variant

Topic summary

A developer is working on code that dynamically updates product availability messages when users select different variants, without requiring a page refresh. The current implementation successfully changes messages based on variant selection.

Current Issue:

  • Attempting to enhance the availability check by verifying if inventory_quantity is non-zero
  • The inventory_quantity variable is not being recognized by the code

Code Context:

  • The provided code snippet appears reversed/obfuscated (text is backwards)
  • Logic checks variant availability and displays French messages about fabrication/delivery times
  • Uses forEach iteration over a backorder collection

Status: The question remains unanswered. The developer is seeking assistance to properly access and validate the inventory quantity property for variant availability checks.

Summarized with AI on November 21. AI used: claude-sonnet-4-5-20250929.

Hello,
I have this code below that works fine, this code is used, when we select another variant, the message is changed without the necessity of updating the page.

But I want to change the availability check of the variant by checking if its inventory is non-zero.

Unfortunately, I am encountering a problem because the “inventory_quantity” variable is not recognized by the code. Could someone help me to solve this problem?

      if (backorder.length) {
        backorder.forEach((element) => {
          if (variant) {
            if (variant.available) {
              element.innerHTML = ' ';
            } else {
              element.innerHTML = 'Votre bijou est en fabrication et vous sera livré sous 6 semaines.';
            }
          } else {
            element.innerHTML = theme.strings.unavailable;
          }
        });
      }