AnsweredAssumed Answered

Using Velocity Scripting with multiple instances of one variable

Question asked by 3f5dd9c25ed8144b7e8aec8da865e1ab273bb194 on May 26, 2017
Latest reply on May 30, 2017 by 3f5dd9c25ed8144b7e8aec8da865e1ab273bb194



We are trying to use velocity scripting in a token in order to generate emails for abandoned shopping carts.

The below text is part of a token we can insert into emails, and the Shopping Cart is a custom object. This code works in our tests for giving the information for one product. However, we haven't been able to alter it to make it display information for multiple products. Even if we have multiple kinds of products loaded into the lead, we can't seem to figure out how to alter the script to reflect the below information for each product in the cart.



You left the following item in your shopping cart. Don't forget about it!





                <br> Price: ${esc.d}${shoppingCart_cList.get(0).itemPrice}


                <br> Quantity: ${shoppingCart_cList.get(0).itemQuantity}


                <br> Line Amount: ${esc.d}${shoppingCart_cList.get(0).extendedLineAmount}



Do we need to create multiple shopping cart/item variables to make this happen? For instance, having itemDescription2, itemImageUrl2, etc.? I tried experimenting with if statements and a foreach, but I'm a complete beginner, so even just some hints would be very helpful. I can't seem to find any research online to help me understand how I need to alter our script.