Displaying Merchant Fields in Order Email with nVelocity
Posted: Tue Apr 08, 2008 3:26 pm
I need to have each product's Merchant Fields listed when the order email is sent. The pre-loaded email templates look like they already provide this functionality, but it also doesn't seem to work. The product in question is linked to a Product Template that has 10 merchant fields. These Merchant fields all have data for the product being ordered, but they aren't coming through in the email.
Thanks,
Josh
Here is a snippet of the nVelocity code I'm using:
<table class="Email">
<tr>
<td style="background:#cccccc; color:#00000; text-align: center;"><strong>SKU</strong></td>
<td style="background:#cccccc; color:#00000; text-align: center;"><strong>Name</strong></td>
<td style="background:#cccccc; color:#00000; text-align: center;"><strong>Price</strong></td>
<td style="background:#cccccc; color:#00000; text-align: center;"><strong>Quantity</strong></td>
<td style="background:#cccccc; color:#00000; text-align: center;"><strong>Total</strong></td>
</tr>
#each
#if (($orderItem.OrderItemType == "Product"))
<tr>
<td class="Email" style="text-align: center;">$orderItem.Sku</td>
<td class="Email">
$orderItem.Name
#if ($orderItem.VariantName.Length > 0)
($orderItem.VariantName)
#end
#########################
# First Attempt to List Merchant Fields
#########################
#foreach($orderItemInput in $orderItem.Inputs)
<br /><b>$orderItemInput.Name:</b> $orderItemInput.InputValue
#end
#########################
# Second Attempt to List Merchant Fields
#########################
#foreach($tf in $orderItem.TemplateFields)
#if ($tf.InputField.IsMerchantField)
${tf.InputField.Name}: $tf.InputValue<br>
#else
Not Merchant Field
#end
#end
</td>
<td class="Email" style="text-align: right;">$orderItem.Price.ToString("C")</td>
<td class="Email" style="text-align: center;">$orderItem.Quantity</td>
<td class="Email" style="text-align: right;">$orderItem.ExtendedPrice.ToString("C")</td>
</tr>
#end
#afterall
</table>
#end
Thanks,
Josh
Here is a snippet of the nVelocity code I'm using:
<table class="Email">
<tr>
<td style="background:#cccccc; color:#00000; text-align: center;"><strong>SKU</strong></td>
<td style="background:#cccccc; color:#00000; text-align: center;"><strong>Name</strong></td>
<td style="background:#cccccc; color:#00000; text-align: center;"><strong>Price</strong></td>
<td style="background:#cccccc; color:#00000; text-align: center;"><strong>Quantity</strong></td>
<td style="background:#cccccc; color:#00000; text-align: center;"><strong>Total</strong></td>
</tr>
#each
#if (($orderItem.OrderItemType == "Product"))
<tr>
<td class="Email" style="text-align: center;">$orderItem.Sku</td>
<td class="Email">
$orderItem.Name
#if ($orderItem.VariantName.Length > 0)
($orderItem.VariantName)
#end
#########################
# First Attempt to List Merchant Fields
#########################
#foreach($orderItemInput in $orderItem.Inputs)
<br /><b>$orderItemInput.Name:</b> $orderItemInput.InputValue
#end
#########################
# Second Attempt to List Merchant Fields
#########################
#foreach($tf in $orderItem.TemplateFields)
#if ($tf.InputField.IsMerchantField)
${tf.InputField.Name}: $tf.InputValue<br>
#else
Not Merchant Field
#end
#end
</td>
<td class="Email" style="text-align: right;">$orderItem.Price.ToString("C")</td>
<td class="Email" style="text-align: center;">$orderItem.Quantity</td>
<td class="Email" style="text-align: right;">$orderItem.ExtendedPrice.ToString("C")</td>
</tr>
#end
#afterall
</table>
#end