Add to Cart
Adds a single entry_id
(item) or on-the-fly item to the cart.
This tag does not generate "add to cart" links, it actually adds items to your cart.
If there is an add_to_cart
tag on your page, an item will be added automatically, and
the customer will be redirected if the return parameter is set.
You can link to a page containing this tag, and it will automatically
add a product to the cart. This is very useful when you use off-site
add to cart links, for AJAX operations, or where you want a customer's
cart to be prepopulated with items.
See also:
Table of Contents
Parameters
- entry_id="{segment_3}"
- quantity="12"
- return="cart/view_cart"
- license_number="yes"
- tax_exempt="yes"
- shipping_exempt="yes"
- show_errors="no"
- item_options:your_option_name="small"
entry_id
The entry id of the product to add.
entry_id="{segment_3}"
quantity
The quantity of this product to add to cart.
quantity="12"
return
This is the URL you'd like the site redirected to when the operation is complete. If left blank, the page will not redirect.
return="cart/view_cart"
license_number
Whether a licence number should be associated with this product. Licence numbers are assigned at checkout.
license_number="yes"
shipping_exempt
Handy for donations and items that don't require taxation.
shipping_exempt="yes"
shipping_exempt
Turns off shipping calculations for this item.
shipping_exempt="yes"
show_errors
Set to "no" to suppress any errors from being shown upon form submission. Defaults to "yes".
show_errors="yes"
item_options:your_option_name
Set item_options
as a tag parameter.
item_options:your_option_name="small"
Examples
To use this tag, the most common method is to create a link to a page containing the tag:
<a href="{entry_id_path=cart/my_add_to_cart_template}" >Buy Now »</a>
Then create a template containing nothing more than the add_to_cart
tag. This example will add the product, and redirect the customer to the
cart/index page.
{exp:cartthrob:add_to_cart entry_id="{segment_3}" quantity="1" return="cart/index"}
If using this on a page with other content to automatically add an item to cart, leave off the return parameter.
{exp:cartthrob:add_to_cart entry_id="{segment_3}" quantity="1" }
<h2>You've added item {segment_3} to your cart! Check out now!</h2>
{exp:cartthrob:checkout_form......