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

Is In Cart

{exp:cartthrob:is_in_cart} checks whether a cart contains an item with a specific entry_id.

You can use it as a single tag or as a tag pair.

See also:

Parameters

entry_id

Entry ID of the product to check.

entry_id="123"

Output and Behavior

  1. entry_id is required to perform the check.
  2. The check matches cart items by entry_id.
  3. Single-tag output is truthy when a match is found ("1" in template comparisons), otherwise empty/false.
  4. In tag-pair mode, both {is_in_cart} and {item_in_cart} are available as equivalent booleans.

Examples

Single-tag conditional

{if '{exp:cartthrob:is_in_cart entry_id="{segment_3}"}' == "1"}
    This item is already in your cart!
{/if}

Tag-pair conditional

{exp:cartthrob:is_in_cart entry_id="123"}
    {if is_in_cart}
        This item is already in your cart!
    {/if}
{/exp:cartthrob:is_in_cart}