Attention: The Marketo Community will undergo scheduled maintenance on Tuesday, August 20th between 10-11 PM PDT. During this time, the Community and its content will not be accessible. We apologize for any inconvenience this may cause.
I am trying to create a velocity scripting table that is able to add the total amount of what a person purchased. I am able to pull all the Custom Object data in, but have not successfully added multiple variables. I did find the $math.add( object1, object2 ) function but have been unable to render correctly the $transaction.price if the user has multiple transactions. Has anyone had success adding multiple variables in Velocity Scripting? Current code pasted below.
#set ( $totalprice = 0 )
<table border="1">
<tr>
<th>Product Description</th><th>Last Four CC</th><th>Shipping Address</th><th>Shipping Date</th><th>Amount</th>
</tr>
#foreach($transaction in $transactions_cList)
<tr>
<td>$transaction.description</td>
<td>$transaction.lastfour</td>
<td>$transaction.shippingstreetaddress</td>
<td>$transaction.requiredshipdate</td>
<td>$transaction.price</td>
</tr>
#end
<tr>
<td colspan=5>Total: </td>
</tr>
</table>
Solved! Go to Solution.
I don't know where you were trying to do the math. Have you done:
#set( $totalPrice = 0)
#foreach( $transaction in $transaction_cList )
#set ( $totalPrice = $math.add( $totalPrice, $transaction.price ) )
#end
Excellent Sanford.
That is exactly what I was missing!