Display Cart Information within Catalog

Display Cart Information within Catalog

The following code snippets will show you how to:

  1. Display the cart item count
  2. Display the number of units (sum of the item quantities)
  3. Display the cart subtotal
  4. Display a greet to the logged in customer
Cart Item Count
$cart.getItemCount()
Display the number of units
#set ($units = 0)
#foreach ($cartItem in $cart.getItems())
  #set ($units = $units + $cartItem.getQuantity())
#end
You have $units unit(s) in your cart.
Cart Subtotal
$cart.getSubTotal()
Greet Logged in Customer
#if ($cart.getCustomerProfile())
  Welcome back $cart.getCustomerProfile().getFirstName()
#end