Use Velocity script to display dynamic content from Marketo custom field
Hi Team,
I need to use Velocity Script to show multiple product information from the Abandoned Cart Custom field in an email. The JSON object below has been stored in a Marketo custom field. Usually, we store cart values in a custom object, but in this case, they need to be stored in a custom field. I'm having difficulty converting the JSON data into a foreach loop.
@sanfordwhiteman @darshil_shah1 Could you please take a look at this and provide your insights?
{
"abandoned_cart": {
"11": {
"product_name_1": "ABCS",
"product_image_1": "3282.jpg",
"catalog_1": "960-13",
"quantity_1": "3",
"unit_1": "EA",
"tabl_value_2": "18 Mars 2019"
},
"13": {
"product_name_1": "BCSDA",
"product_image_1": "33282.jpg",
"catalog_1": "9610-1",
"quantity_1": "3",
"unit_1": "IN",
"tabl_value_2": "04 avril 2019"
},
"15": {
"product_name_1": "RTYU",
"product_image_1": "282.jpg",
"catalog_1": "6410-3",
"quantity_1": "3",
"unit_1": "US",
"tabl_value_2": "15-Avril-2019"
}
}
}My velocity script:
#if( $lead.abandonedcart.isEmpty() )
#set( $lead.abandonedcart = '[]' )
#else
#set( $CartDetails = '#set( $CartDetails = ' + $lead.abandonedcart + ' )' )
#evaluate( $CartDetails )
## print $CartDetails
#endThanks,
Karthik