CartThrob 9 documentation for ExpressionEngine commerce teams Visit CartThrob.com
CartThrob.com

Is In Stock

is_in_stock checks whether a product is currently in stock and returns a boolean-style result.

See also:

Parameters

entry_id

Required numeric product entry ID.

If entry_id is missing or not numeric, the tag returns false-like output.

entry_id="123"

Behavior and Constraints

  1. This is an immediate-execution single tag.
  2. Tag loads product data using ee()->cartthrob->get_product(entry_id).
  3. If product cannot be loaded, result is false-like output.
  4. If product is loaded, tag returns $product->in_stock().
  5. in_stock() checks inventory as inventory(item_options) > 0.
  6. This tag does not accept item-option parameters, so option-specific inventory selection is not configurable through this tag.
  7. Inventory resolution still runs through product inventory logic/hook path (including inventory calculation hooks), but with no item-options input from tag parameters.
  8. Codebase audit note: no installer/stub template usage for this tag was found in current repository templates.

Examples

Conditional stock message:

{if '{exp:cartthrob:is_in_stock entry_id="123"}'}
    In Stock
{if:else}
    Out of Stock
{/if}

Use with channel entry ID:

{if '{exp:cartthrob:is_in_stock entry_id="{entry_id}"}'}
    <button type="submit">Add to Cart</button>
{if:else}
    <span>Sold Out</span>
{/if}