Cart Items Info
The cart_items_info
tag works similar to the channel entries module,
and is intended to print out the contents of the customer's cart. This
tag outputs all details related to the contents of the cart, item
details, subtotals, totals, shipping and tax figures (if available).
This tag is usually a key component of a cart based site. This tag is
what you will use to provide visitors an overview of what is in their
cart, and generally what you will use as the base to access tools to
edit & update products and quantities, and remove items from the cart.
A video tutorial on this tag is available..
Table of Contents
Parameters
In addition to the parameters below, you may also use parameters found in Global Number Formatting.
orderby
Orders the output. You can order by: title, quantity, entry_id
,
row_id
, price, or item_options:your_option_name
, channel_id
, your_custom_field_name
. CartThrob uses a data filter to order items, so you'll often find that if you can output a variable using the cart_items_info
tag, you'll also be able to orderby that variable.
orderby="title"
sort
Sets the sort order
sort="asc"
number_format
This will override default formatting to totals, subtotals, etc.
number_format="yes"
limit
Limits the number of items shown
limit="1"
offset
Handy if you want to paginate or otherwise offset the items returned.
offset="10"
entry_id
This parameter pulls up data for one (or more) specific items. Separate multiple entry_ids with a pipe "|" character.
entry_id="456|455|454"
plan_id
This parameter pulls up data for one (or more) subscription plans. Separate multiple plan_ids with a pipe "|" character.
plan_id="456|455|454"
row_id
This parameter pulls up data for one (or more) specific items. Separate multiple row_ids with a pipe "|" character. This is useful for pulling up information about specific items in the cart, especially when you may have one or more items with the same entry ID in multiple configurations.
row_id="456|455|454"
search:field_name
Note: This feature is still under development, pending user feedback.
This parameter allows you to filter which cart items are shown in this loop.
Contains matching
//items whose product tag contain the word
search:product_tag="pickles"
//items whose product tag contains one of the words
search:product_tag="pickles|shoes"
//items whose product tag does not contain one of the words
search:product_tag="not pickles|shoes"
//items whose product tag contains all of the words
search:product_tag="pickles&&shoes"
//items whose product tag contains none of the words
search:product_tag="not pickles&&shoes"
Exact matching
//items whose product tag is exactly the word
search:product_tag="=pickles"
//items whose product tag is exactly one of the words
search:product_tag="=pickles|shoes"
//items whose product tag is exactly neither of the words
search:product_tag="=not pickles|shoes"
Numeric comparisons
//items whose price is less than 10
search:price_numeric="<10"
//items whose price is greater than or equal 10
search:price_numeric=">=20"
Variables
In addition to the variables listed here, you may also use any of the Global Tag Variables.
- entry_id
- title
- url_title
- quantity
- row_id
- item_price
- item_price:plus_tax
- base_price
- base_price:plus_tax
- item_subtotal
- item_subtotal:plus_tax
- item_shipping
- item_weight
- total_items
- total_unique_items
- cart_total
- cart_subtotal
- cart_subtotal:plus_tax
- cart_tax
- cart_shipping
- cart_shipping:plus_tax
- cart_tax_name
- cart_discount
- cart_count
- entry_id_path
- row_id_path
- item_options:your_option
- item_options:your_option:option_name
- item_options:your_option:price
- switch
entry_id
channel or other product entry ID used to identify the product
{entry_id}
121
title
Product's title
{title}
Grayskull Frontispiece
url_title
Product's URL title if product is stored in a channel
{url_title}
grayskull_frontispiece
quantity
Quantity of product stored in cart
{quantity}
1
row_id
The row_id
of the item.
{row_id}
2
item_price
Individual product price
{item_price}
22
item_subtotal
Product price multiplied by quantity
{item_subtotal}
23.95
item_shipping
Shipping cost for this item
{item_shipping}
1.95
item_weight
The weight for this item.
{item_weight}
15
discounted_price
The discounted price of the item
discounted_price:numeric
The discounted price of the item without formatting applied
discount
The discount applied to this item
discount:numeric
The discount applied to this item without formatting applied
total_items
Total items in cart
{total_items}
10
total_unique_items
Total unique items in cart.
{total_unique_items}
19
cart_total
Total cost of items in cart
{cart_total}
24.95
cart_subtotal
Subtotal of the cart before tax and shipping, after discounts have been applied
{cart_subtotal}
24.95
cart_tax
Amount of tax currently applied to cart contents
{cart_tax}
1.00
cart_shipping
Shipping amount applied to cart contents
{cart_shipping}
.95
cart_tax_name
The label given to your tax setting.
{cart_tax_name}
Gloucester
cart_discount
The amount of the discount applied to the cart.
{cart_discount}
15
cart_count
The current iteration of the cart_items_info
loop. Similar to {count}
in a channel entries tag.
{cart_count}
1
entry_id_path
The entry_id
path for the current item.
{entry_id_path=products/detail}
row_id_path
The row_id
path for the current item.
{row_id_path=cart/delete_from_cart}
item_options:your_option
The specified item_option
for the current item.
{item_options:your_option}
XL
item_options:your_option:option_name
The option_name
for the specified item_option
.
item_options:your_option:option_name
Extra Large
item_options:your_option:price
The price of the specified item_option
.
{item_options:your_option:price}
$12.00
switch
{switch="option1|option2"} will allow you to easily create "zebra rows" by switching automatically between items. For instance
<tr class="option1">... <tr class="option2">
option1|option2
base_price
Displays the price of the item without any item options added to it.
{base_price}
base_price:plus_tax
Displays the price of the item without any item options added to it plus tax
{base_price:plus_tax}
item_price:plus_tax
Displays the price of the item with item options costs added to it plus tax
{item_price:plus_tax}
item_subtotal:plus_tax
Displays the price of the item * quantity with item options costs added to it plus tax
{item_subtotal:plus_tax}
cart_subtotal:plus_tax
Displays the price of the cart plus tax
{cart_subtotal:plus_tax}
cart_shipping:plus_tax
Displays the price of shipping plus tax
{cart_shipping:plus_tax}
Conditionals
{if no_items}
Since cart_items_info
is a loop, if there is nothing in the cart, none
of the variables above will be rendered. Use the no_items
conditional
to output alternate content when there is nothing in the cart.
{if no_items}There's nothing in your cart{/if}
{if is_package}
Displays content if the item is a package item
{if is_package} This is a package! {/if}
{if is_subscription}
Displays content if the item is a subscription item
{if is_subscription} This is a subscription! {/if}
{if item_options}
Displays if there are item options applied to this item.
{if item_options} This item has options applied to it {/if}
{if first_row}
Only displays for the first item.
{if first_row}<table><tr>{/if}
{if last_row}
Only displays for the last item.
{if last_row}</tr></table>{/if}
Examples
{exp:cartthrob:cart_items_info}
<a href="{path='products/detail/{url_title}'}">{title}</a><br />
{/exp:cartthrob:cart_items_info}