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

Determine if a Cart Has Shippable Items

{exp:cartthrob:has_shippable_items} checks whether the active cart contains at least one shippable product.

See also:

Parameters

This tag has no parameters.

Output

This tag returns a boolean result:

  • true when at least one cart item is backed by a product entry with product_shippable set to Yes.
  • false when no matching shippable product is found.

When printed directly, the output may appear as a truthy/empty value depending on template rendering. Use conditionals for predictable template logic.

Behavior and Constraints

  1. Iterates current cart items.
  2. For each item, loads the related product entry data (if a product_id exists).
  3. Checks the product_shippable entry variable.
  4. Returns true immediately on the first product where product_shippable == 'Yes'.
  5. Returns false if no matching item is found.

Important nuance:

  • This tag checks product-entry shippable flags, not the current shipping total amount.
  • Items without a valid product entry are ignored by this check.

Examples

Basic check

{exp:cartthrob:has_shippable_items}
{if '{exp:cartthrob:has_shippable_items}'}
    Show shipping address fields
{if:else}
    Hide shipping-only fields for digital-only cart
{/if}

Pair with shipping total logic

{if '{exp:cartthrob:has_shippable_items}'}
    {if "{exp:cartthrob:has_shipping}" == "TRUE"}
        Shipping has been calculated.
    {/if}
{/if}