Update Cart Form (tag pair)

This tag allows you to update one or more products in your shopping cart. You can also delete one or more items at the same time, or the contents of the entire cart. This tag makes it easy to modify lots of cart information at the same time. Additionally, this tag will allow you to add and edit customer information (names, shipping options, locations) at the same time as you're editing product information (see save_customer_info_form for supported customer info fields).

A video tutorial on this tag is available..

Array Indexes

Each product must be given a unique array key. You can use a variable like {count}, {entry_id}, or {row_id} or manually insert a number in the index. The index numbers do not need to be sequential, as long as they are unique to separate each product. Each field of data being sent along should have a matching array key to group attributes together. In the example below, 1 and 2 are used as the array keys.

Product 1
<input type="hidden" name="entry_id[1]" value="{entry_id}" />
<input type="text" name="quantity[1]" />
<input type="text" name="item_options[1][notes]" />

Product 2
<input type="hidden" name="entry_id[2]" value="{entry_id}" />
<input type="text" name="quantity[2]" />
<input type="text" name="item_options[2][notes]" />

Table of Contents

Parameters

See Global Form Parameters.

Variables

You may use any of the Global Tag Variables.

Form Fields

clear_cart

Add this field to delete all the items in the cart at once.

<input type="submit" name="clear_cart" value="Clear Cart" />

quantity[{row_id}]

This input will allow you to adjust the quantity of an item.

<input type="text" name="quantity[{row_id}]" size="2" value="{quantity}" />

delete[{row_id}]

Choose multiple items to delete.

<input type="checkbox" name="delete[{row_id}]">

Examples

Please review the note about array indexes in the overview at the top of this page.

{exp:cartthrob:cart_items_info}
    {if first_row}
        {exp:cartthrob:update_cart_form  return="cart/index"}
    {/if}
    {title}
    <input type="text" name="quantity[{row_id}]" size="2" value="{quantity}" />
    {!-- This deletes lets you select multiple row_ids --}
    <input type="checkbox" name="delete[{row_id}]"> Delete this item
    {if last_row}
        <input type="submit" value="Update Cart" />
        {/exp:cartthrob:update_cart_form}

    {/if}
{/exp:cartthrob:cart_items_info}