Skip to main content

Introduction

This tutorial shows how to use Velocity code on your catalog to conditionally show the item count and total of the customer cart . This velocity code example is intended to be used within the catalog templates section of UltraCart.

note

Main MenuCatalog → Choose the host → Manage Catalog Templates

Sample Code

#if($cart)
<a href="$checkoutUrlHttps">My Cart Total <span class="total">$cart.getSubTotal()</span></a>
#else
<a href="$checkoutUrlHttps">My Cart Total <span class="total">$0.00</span></a>
#end

Break Down

#if($cart)

Here we check to see if the customer has a cart session started. Meaning they have an item within the cart, if this is true then we display the following:

<a href="$checkoutUrlHttps">My Cart Total <span class="total">$cart.getSubTotal()</span></a>

Here we use the tag $cart.getSubTotal()" to pull the total from the checkout and display that information to the customer.

If the customer does not have a item in the cart (or checkout) then the following is used:

#else
<a href="$checkoutUrlHttps">My Cart Total <span class="total">$0.00</span></a>
#end

This simply display an area for the information to go but does not contain any information because the customer has not added anything to their cart.

Was this page helpful?