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

Get Items In Range

{exp:cartthrob:get_items_in_range} returns product entries whose configured price field falls within a min/max range.

This tag is best used as a tag pair so you can output product variables (title, entry ID, paths, custom fields, etc.) for matching entries.

See also:

Parameters

price_min

Minimum product price filter.

price_min="10"

If omitted as a tag parameter, this value is read from request input (price_min).

price_max

Maximum product price filter.

price_max="20"

If omitted as a tag parameter, this value is read from request input (price_max).

variable_prefix

Optional prefix for output variables to avoid naming conflicts in nested templates.

variable_prefix="range_"

Variables

Each matched product row is output using product entry variables from CartThrob’s entries model.

Commonly used variables include:

  • {entry_id}
  • {title}
  • {url_title}
  • path variables such as {entry_id_path='group/template'}
  • custom product fields from the matched product entry

If variable_prefix is used, variables are also available with that prefix (for example {range_entry_id}, {range_title}).

Conditionals

{if no_results}

Displays fallback content when no products match the range.

{if no_results}No products found in this range.{/if}

Behavior and Constraints

  1. price_min and price_max are XSS-cleaned and must be numeric; non-numeric values are ignored.
  2. If both min and max are empty/non-numeric, the tag returns no output.
  3. Product matching is based on configured CartThrob product channels and their mapped price fields.
  4. Results are returned as matched product rows (tag pair output), not as a pipe-delimited list.
  5. If no matching IDs are found, no results output is returned.

Examples

Basic range listing:

{exp:cartthrob:get_items_in_range price_min="10" price_max="25"}
    <li><a href="{entry_id_path='store/product_detail'}">{title}</a></li>
    {if no_results}
        <li>No products found in this range.</li>
    {/if}
{/exp:cartthrob:get_items_in_range}

Using request input fallback (price_min / price_max from query string or post data):

{exp:cartthrob:get_items_in_range}
    {title}<br />
{/exp:cartthrob:get_items_in_range}

Using a variable prefix in nested templates:

{exp:cartthrob:get_items_in_range price_min="10" price_max="55" variable_prefix="range_"}
    {range_title} ({range_entry_id})<br />
{/exp:cartthrob:get_items_in_range}