Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

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.

Sample Code

#if($cart)
  <a href="$checkoutUrlHttps">My Cart ($cart.getItemCount() Items) </span></a>
#else
  <a href="$checkoutUrlHttps">My Cart (0 Items)</a>
#end

Break Down

Condition
#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:

Statement 1
<a href="$checkoutUrlHttps">My Cart ($cart.getItemCount() Items)</span></a>

 Here we use tags for both " $cart.getItemCount()" and " $cart.getSubTotal()" to pull both the item count and the carts total and display that information to the customer.

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

Condition 2 and End Statement
#else
  <a href="$checkoutUrlHttps">My Cart (0 Items)</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.

 

  • No labels