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
- This is an immediate-execution single tag.
- Tag loads product data using
ee()->cartthrob->get_product(entry_id). - If product cannot be loaded, result is false-like output.
- If product is loaded, tag returns
$product->in_stock(). in_stock()checks inventory asinventory(item_options) > 0.- This tag does not accept item-option parameters, so option-specific inventory selection is not configurable through this tag.
- Inventory resolution still runs through product inventory logic/hook path (including inventory calculation hooks), but with no item-options input from tag parameters.
- 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}