Home > The Template System > Process Templates > The Shopping Cart Template

Table of Contents

DotAdmin User Guide

The Shopping Cart Template

The cart template is included in three different process pages. First, the cart process uses this template to allow the visitor to edit the contents of his or her cart, and the template is also used as part of the checkout and receipt stages of the payment process to display the contents of the order.

The Shopping Cart Template
The Shopping Cart Template.

BLOCK {errors}

Errors in the cart are related to stock levels, or orders that for some other reason cannot be fulfilled. BLOCK {errors} contains all the error messages that the cart can display. They are shown in the code fragment below.

<!-- BLOCK {errors} -->

  <!-- IF {out_of_stock} -->
    <p><b>Sorry,</b> this item is out of stock and unavailable.</p>
  <!-- /IF {out_of_stock} -->

  <!-- BLOCK {low_stock} -->
    <p><b>{title}:</b> Sorry, you tried to order {quantity} but we
    only have {stock} of this item remaining.</p>

    <!-- IF {add_this} -->
      <p><a href="/content/cart/?rz={rz}&rp={rp}&a={action}
      &product_code={product_code}&quantity={stock}" title="Add
      {stock} more '{title}' to your basket">click here to order
      all {stock} remaining items.</a></p>
    <!-- /IF {add_this} -->

  <!-- /BLOCK {low_stock} -->

  <!-- IF {one_only_msg} -->
    <p>You cannot order more than one of this item: {title}.</p>
  <!-- /IF {one_only_msg} -->

  <!-- IF {use_edit_msg} -->
    <p>You already have {quantity} {title} in your cart. Please edit
    the quantity below if you want to add more.</p>
  <!-- /IF {use_edit_msg} -->

  <!-- IF {one_subs_only} -->
    <p>The item you tried to order ({new_sub}) is paid for using
    repeat payments, but you already have another item which is
    paid for in this way ({old_sub}) in your basket. Only one of
    these types of products may be added to an order.</p>
  <!-- /IF {one_subs_only} -->

<!-- /BLOCK {errors} -->

Error messages in the Cart template.

Note that all the above messages are contained within conditional instructions, with the exception of the {low_stock} warning, which is enclosed by a BLOCK. This is because {low_stock} contains a conditional instruction (IF {add_this}). Conditions cannot contain other conditions, and so a BLOCK is used for the {low_stock} message.

IF {has_items}

This is the section of the template where the actual shopping cart is displayed. The IF {has_items} condition only displays its contents if the shopping cart contains at least one product.

The IF {has_items} Section of the Shopping Cart Template.
The IF {has_items} Section.

As shown in the image above, each type of product in the cart is displayed in its own row by BLOCK {cart_items}, with the exception of subscription-type products (see below). BLOCK {header} is used to remove the cart table headings if there are no “regular” products to display (if the only product in the cart is a subscription).

Note: The {cart_items_locked} and {cart_subs_locked} blocks are used instead of {cart_items} and {cart_subs} when the cart is displayed within the checkout and receipt pages. This simply removes the form controls to stop the contents of the cart from being edited.

Subscription Products in the Shopping Cart

Subscriptions are paid for using a repeat payment agreement, which is an arrangement to make payment in installments over a given period of time. Because this payment is not made immediately, it is displayed outside of the normal shopping cart in BLOCK {cart_subs} to note that it represents a separate transaction.

The only exception is where a repeat payment agreement is made which requires the first installment to be paid immediately. In this case, the first payment is displayed as a line in the regular shopping cart and will be part of that transaction (as shown in the example above). The agreement and the date of the next payment are then described in the {cart_subs} block as normal.

BLOCK {costs}

The costs block contains five other blocks which display the total value of the customer's order. If the customer's location is not known, only the {subtotal} block is displayed. Once the shipping destination for the order is known, the cart will then enable the other blocks to display any appropriate shipping costs, taxes and a full total value for the order.

BLOCK {mainbuttons}

This block contains links pointing back to the page the customer arrived from, and on to the checkout stage of the store. The only placeholders in here are the {rz} and {rp} values which point to the referring page the customer arrived from.

BLOCK {shipping}

This block shows a drop-down list of countries or regions from which the customer can select a shipping destination for the order. Selecting a shipping location here allows the customer to view the final total cost of the order as items are added to the cart, rather than waiting until the checkout address details are completed to find out the full value of the order.

BLOCK {suspended}

This block should be outside of the IF {has_items} condition. It is used to display a message to the visitor stating that the online store is not currently available, in case the store operator has placed the store in “suspended” mode for any reason.

Below is a summary of all template elements found in the cart template:

Placeholder Output
BLOCK {errors} Any errors resulting from products being added to the shopping cart are reported within this block.
IF {out_of_stock} Inside BLOCK {errors}, this condition can be used to display an out-of-stock message to the customer, if he adds a product to the cart which is unavailable.
BLOCK {low_stock} Inside BLOCK {errors}, informs the customer if he tries to order more stock than is available.
IF {add_this} Inside BLOCK {low_stock}, offers a link for the customer to add all remaining stock of a particular item to the cart.
IF {only_one_msg} Inside BLOCK {errors}, tells the customer that he may only order one of this item. Mostly used when selling downloadables or subscriptions.
IF {use_edit_msg} Inside BLOCK {errors}, asks the user to edit the quantity of a given item in the cart screen, rather than adding more from the product page, if the item is already in the cart.
IF {one_subs_only} Inside BLOCK {errors}, if the user tries to arrange two different repeat payment agreements (used for subscriptions), this message reports that only one agreement can be processed at a time.
IF {has_items} Contains cart elements to be displayed if the cart contains something. Avoids an empty shopping cart being displayed.
BLOCK {header} Inside IF {has_items}, contains column headers for the shopping cart display.
BLOCK {cart_items} Inside IF {has_items}, repeats to show details of each product added to the cart.
IF {allow_edit} Inside BLOCK {errors}, tells the customer that he may only order one of this item. Mostly used when selling downloadables or subscriptions.
IF {use_edit_msg} Inside BLOCK {cart_items}, allows removal of quantity edit controls for items which can only be ordered in quantities of one (usually downloadables or subscription payments).
BLOCK {cart_items_locked} Inside IF {has_items}, repeats to show details of each product added to the cart, but with all form controls removed, for use in the checkout and receipt stages of the store.
BLOCK {costs} Inside IF {has_items}, contains blocks used to display price totals for the contents of the cart.
BLOCK {subtotal} Inside BLOCK {costs}, shows the combined value of all items added to the cart.
BLOCK {shipping} Inside BLOCK {costs}, displays any shipping costs for the order.
BLOCK {tax_a} Inside BLOCK {costs}, displays tax expenses for this order, where applicable, using Tax A.
BLOCK {tax_b} Inside BLOCK {costs}, displays tax expenses for this order, where applicable, using Tax B.
BLOCK {total} Inside BLOCK {costs}, displays the sum of all the above cost blocks.
BLOCK {costs} Inside BLOCK {costs}, contains blocks used to display price totals for the contents of the cart.
{literal currency} Inside each subtotal cost block, displays the currency symbol (For example: £).
{value} Inside each subtotal cost block, displays the cost associated with the block.
BLOCK {cart_subs} Inside IF {has_items}, displays details of a repeat payment agreement if one is added to the order.
BLOCK {cart_subs_locked} Inside IF {has_items}, displays details of a repeat payment agreement with the form controls removed so it cannot be edited.
{number} Inside the two subscription blocks, displays the number of payments in the agreement.
{literal currency} Inside the two subscription blocks, displays the currency symbol (For example: £).
{price} Inside the two subscription blocks, shows the cost of each individual payment.
{count} Inside the two subscription blocks, in conjunction with ‘interval’ shows how often payments will be made (For example: 4 [count] weeks[interval]).
{interval} Inside the two subscription blocks, in conjunction with ‘count’ shows how often payments will be made (For example: 4[count] weeks[interval]).
{start_date} Inside the two subscription blocks, shows the date that the first subscription payment will be taken.
BLOCK {tax} Inside the two subscription blocks, shows any appropriate tax costs associated with each payment.
{tax_amount} Inside BLOCK {tax}, shows the cost of applying this tax.
{tax_name} Inside BLOCK {tax}, shows the name of the tax being applied.
BLOCK {mainbuttons} Inside IF {has_items}, used to show links back to the referring product page and to the checkout stage.
BLOCK {shipping} Inside IF {has_items}, contains mark-up to show a shipping location selector to the customer.
BLOCK {options} Inside BLOCK {shipping}, repeats to display an option for each region that the store ships to.
IF {b_selected} Inside BLOCK {options}, used to pre-select an option when the page loads, if an option has been chosen by the customer.
{destination} Inside BLOCK {options}, displays the name of the region to be shipped to.
BLOCK {suspended} Shows a message to report that the store is not available if the merchant has disabled the store.
{stock} Inside BLOCK {errors}, reports the total stock in hand of the item in question.
{new_sub} Inside BLOCK {errors}, The name of the subscription product the user tried to add to the cart.
{old_sub} Inside BLOCK {errors}, the name of the subscription product already in the cart.
{product_code} Found in various blocks, displays the reference code for a sale unit.
{quantity} Found in various blocks, displays a figure relating to the quantity of a product ordered.
{title} Found in various blocks, usually refers to the name of a sale unit. In the Tax A and Tax B cost blocks, refers to the name of the tax in question.
{unit_price} Found in BLOCK {cart_items} and {cart_items_locked}, shows the cost of an individual sale unit.
{price} Found in BLOCK {cart_items} and {cart_items_locked}, the cost of the sale unit multiplied by the quantity ordered.
{rz} Found in various blocks, used to pass the ID (url) of the referring zone.
{rp} Found in various blocks, used to pass the ID (url) of the referring page.