Appearance
Cart tag
The cart tag is responsible for creating a cart overview.
The tag
{exp:reinos_store:cart}Tag Parameters
Below are the Tag Parameters. Those parameters can be used in the tag described above
return_url
The return url, default to the current url
return_url=""form_class
Set the form class
form_class=""form_id
Set the form id
form_id=""prefix
Set a prefix for your variables, including the colon. The default is items: (so {items:total}), the examples on this page and the bundled templates use prefix="cart:".
prefix="cart:"can_update
Mark the cart so it can be updated. We add a <form/> tag in the html.
can_update="yes"Tag Variable
Below are the Tag Variables. Those Variables can be used in the tag described above
cart:no_items
Check if there are no_items
{if cart:no_items}...{/if}cart:items
Loop over the items in the cart
{cart:items}
{cart:name}
{cart:price}
{cart:price:formatted}
{cart:old_price} // when dealing with a sale price, this is the original_price
{cart:old_price:formatted} // when dealing with a sale price, this is the original_price
{cart:price_plus_tax}
{cart:price_plus_tax:formatted}
{cart:old_price_plus_tax} // when dealing with a sale price, this is the original_price
{cart:old_price_plus_tax:formatted} // when dealing with a sale price, this is the original_price
{cart:id} // the id of the cart line, used to update or remove it (e.g. name="qty[{cart:id}]")
{cart:qty}
{cart:max_qty} // the max_qty of the add_to_cart tag, 0 is no limit
{cart:sku}
{cart:entry_id}
{cart:weight} // the weight of one product, in the Weight unit of the Store settings
{cart:tax_type} // the tax rate name, e.g. high
{cart:tax_rate} // the tax percentage
{cart:tax} // the tax of one product
{cart:discount_ids} // the IDs of the discounts applied to this item, separated by |
{cart:disable_shipping}
{cart:price_total}
{cart:price_total:formatted}
{cart:old_price_total} // when dealing with a sale price, this is the original_price
{cart:old_price_total:formatted} // when dealing with a sale price, this is the original_price
{cart:price_total_plus_tax}
{cart:price_total_plus_tax:formatted}
{cart:old_price_total_plus_tax} // when dealing with a sale price, this is the original_price
{cart:old_price_total_plus_tax:formatted} // when dealing with a sale price, this is the original_price
{cart:custom_fields}
{cart:custom_fields:name}
{cart:custom_fields:label}
{cart:custom_fields:value}
{cart:custom_fields:is_modifier}
{cart:custom_fields:modifier:price}
{cart:custom_fields:modifier:price:formatted}
{cart:custom_fields:modifier:price_plus_tax}
{cart:custom_fields:modifier:price_plus_tax:formatted}
{/cart:custom_fields}
{cart:on_sale} // bool if the product is on sale
{cart:note}
{cart:parent_order_item_id}
{cart:count}
{cart:abs_count}
{/cart:items}cart:total_items
The total number of different products in the cart
{cart:total_items}cart:total_items_qty
The total qty of all items in the cart
{cart:total_items_qty}cart:subtotal_before_discount
This is the subtotal before any discount is applied.
{cart:subtotal_before_discount}
{cart:subtotal_before_discount:formatted}cart:subtotal_before_discount_plus_tax
This is the subtotal before any discount is applied.
{cart:subtotal_before_discount_plus_tax}
{cart:subtotal_before_discount_plus_tax:formatted}cart:subtotal
{cart:subtotal}
{cart:subtotal:formatted}cart:subtotal_plus_tax
{cart:subtotal_plus_tax}
{cart:subtotal_plus_tax:formatted}cart:discount
To use the coupon code, simply add the field <input type="text" name="coupon_code" value="{cart:coupon_code}"/>. (see the examples for details)
The discount is without tax: it is applied before the tax is calculated.
{cart:discount}
{cart:discount:formatted}cart:discount_plus_tax
Available from v4.0.0
The discount including the tax it takes off. Use this one next to {cart:subtotal_before_discount_plus_tax} and {cart:total_plus_tax}, so the amounts add up.
{cart:discount_plus_tax}
{cart:discount_plus_tax:formatted}cart:discount_ids
The IDs of the discounts applied to the cart, separated by | (e.g. 1|4). Empty when no discount is applied. With Store Price Rule these are the IDs of the cart rules; inside {cart:items}, {cart:discount_ids} holds the IDs of the product rules (or the Buy X Get Y Free rule of a free product) applied to that item.
{cart:discount_ids}cart:error:out_of_stock
Available from v4.0.0
1 when the cart was updated with a higher quantity than the stock allows (when Check the stock is on for the channel, see the Inventory settings). The quantity of that product stays the same.
{if cart:error:out_of_stock}
<p>There is not enough stock for the quantity you entered.</p>
{/if}cart:coupon_code
The coupon code that was entered and is kept in the cart, e.g. to fill the coupon field again.
<input name="coupon_code" value="{cart:coupon_code}">cart:coupon_code_error
Available from v4.0.0
Why the coupon code gives no discount: invalid (the code doesn't exist or is expired) or used (a code for one user that is already used for an order). Empty when there is no code or the code is valid. A refused code is not kept in the cart, the error is shown on the next page. With Store Price Rule, an unknown code gives invalid; Store Price Rule decides the other errors.
{if cart:coupon_code_error == 'used'}
<p>This coupon code has already been used.</p>
{if:elseif cart:coupon_code_error == 'invalid'}
<p>This coupon code is not valid.</p>
{/if}The checkout checks the code again: a code that gives no discount anymore is removed from the cart and the checkout shows {global_error:coupon_code}.
cart:total
{cart:total}
{cart:total:formatted}cart:total_plus_tax
{cart:total_plus_tax}
{cart:total_plus_tax:formatted}cart:tax
{cart:tax}
{cart:tax:formatted}cart:tax_details
The Tax Details tag pair can give you a summary of the TAX. It holds multiple entries when you have multiple tax rates applied to the cart.
Available from v3.6.0
{cart:tax_details}
{cart:tax_details:info} // if you have installed the Tax Module, the info field of the applied rule is shown here
{cart:tax_details:rate}
{cart:tax_details:amount}
{cart:tax_details:amount:formatted}
{cart:tax_details:count} // current count of the item
{cart:tax_details:total_results} // total count of the items
{/cart:tax_details}cart:shipping
{cart:shipping}
{cart:shipping:formatted}cart:shipping_plus_tax
{cart:shipping_plus_tax}
{cart:shipping_plus_tax:formatted}cart:has_free_shipping
Indicate if the cart has free shipping applied by any discount/free shipping rule
{cart:has_free_shipping}cart:entry_ids
Hold all entry_ids as a pipeline delimited string
{cart:entry_ids}cart:is_reverse_charge_eu
This flag indicate if we deal with a customer that has no TAX calculated
Note: this is only filled when Store Tax is installed.
{cart:is_reverse_charge_eu}cart:shipping_method
Return the method for shipping. Please note this is default to native in case you just use the Store module. If you are using the Reinos Store Shipping Module, it will be filled with the method that the customer selected.
Available from v3.7.0
Updating the cart
With can_update="yes" the tag wraps its content in a form. These fields update the cart:
qty[{cart:id}]: the quantity of a product. A quantity of 0 (or below 1, or not a number) removes the product. A quantity above themax_qtyof the product is lowered to it. A higher quantity is checked against the stock, like adding the product: when there is not enough, the quantity stays the same and the cart shows{cart:error:out_of_stock}.note[{cart:id}]: the note of a product.custom_fields[{cart:id}][field_name]: a custom field of a product. The modifiers of a product can't be changed this way, they only come from the add_to_cart tag.coupon_code: the coupon code. An empty field removes the code, a form without the field keeps it.
The quantities and notes are only saved when the form is posted with a submit button named update. The custom fields and the coupon code are saved with any submit button. A submit button named clear empties the cart. After the update the customer goes to the return_url, when it is a url of your own site (otherwise the homepage).
<input type="number" name="qty[{cart:id}]" value="{cart:qty}">
<input type="submit" name="update" value="Update">
<input type="submit" name="clear" value="Clear cart">Example
{exp:reinos_store:cart prefix="cart:" can_update="yes" return_url="store/cart"}
<h1 class="font-bold mt-5 text-2xl">Your cart</h1>
{if cart:no_items}
<p>No cart items</p>
{if:else}
<p class="mb-10 text-italic">({cart:total_items} products in cart and {cart:total_items_qty} items in cart)</p>
<table class="w-full table-auto mt-4 mb-4">
<thead class="border-b-2">
<tr>
<th align="left">Name</th>
<th align="left">Qty</th>
<th align="left">Price</th>
<th align="left">Subtotal</th>
<th />
</tr>
</thead>
<tbody>
{cart:items}
{exp:channel:entries entry_id="{cart:entry_id}" dynamic="no"}
<tr class="border-b">
<td>
<div class="py-3">
<a href="{page_uri}">{title}</a>
{if cart:sku != ''}<small>sku: {cart:sku}</small>{/if}
{cart:custom_fields}
{if cart:custom_fields:is_modifier}
<br><strong>Modifier: {cart:custom_fields:label}:</strong> {cart:custom_fields:value} (+{cart:custom_fields:modifier:price:formatted})
{if:else}
<br><strong>{cart:custom_fields:label}:</strong> {cart:custom_fields:value}
{/if}
{/cart:custom_fields}
</div>
</td>
<td><input class="border p-1 rounded" type="number" value="{cart:qty}" name="qty[{cart:id}]"></td>
<td>
{cart:price_plus_tax:formatted}
{if cart:on_sale} <strike>{cart:old_price_plus_tax:formatted}</strike>{/if}
</td>
<td>
{cart:price_total_plus_tax:formatted}
{if cart:on_sale} <strike>{cart:old_price_total_plus_tax:formatted}</strike>{/if}
</td>
<td align="right">
{exp:reinos_store:delete_cart_item cart_item_id="{cart:id}" return_url="/store"}
<a class="button" href="{remove_cart_item_url}">Remove</a>
{/exp:reinos_store:delete_cart_item}
</td>
</tr>
{/exp:channel:entries}
{/cart:items}
</tbody>
</table>
<div class="w-1/2 flex flex-col ml-auto">
<h3 class="text-lg font-medium mt-5">Coupon code</h3>
<div class="flex gap-x-1 mb-5">
<input class="w-full border p-1 rounded" type="text" name="coupon_code" value="{cart:coupon_code}"/>
<input type="submit" name="update" value="Apply" class="button"/>
</div>
<table>
<tbody>
<tr>
<td align="right"><strong>Subtotal</strong></td>
<td align="right">{cart:subtotal_plus_tax:formatted}</td>
</tr>
{if cart:discount > 0}
<tr>
<td align="right"><strong>Discount</strong></td>
<td align="right">{cart:discount:formatted}</td>
</tr>
{/if}
{if cart:tax > 0}
<tr>
<td align="right"><strong>TAX</strong></td>
<td align="right">{cart:tax:formatted}</td>
</tr>
{/if}
{if cart:shipping_plus_tax > 0}
<tr>
<td align="right"><strong>Shipping</strong></td>
<td align="right">{cart:shipping_plus_tax:formatted}</td>
</tr>
{/if}
<tr>
<td align="right"><strong>Total excl</strong></td>
<td align="right">{cart:total:formatted}</td>
</tr>
<tr>
<td align="right"><strong>Total</strong></td>
<td align="right">{cart:total_plus_tax:formatted}</td>
</tr>
</tbody>
</table>
</div>
<input type="submit" name="update" value="Update" class="button"/>
<input type="submit" name="clear" value="Clear cart" class="button"/>
<a class="button" href="/index.php/store/checkout">Checkout</a>
{/if}
{/exp:reinos_store:cart}