Page 1 of 1

Displaying Merchant Fields in Order Email with nVelocity

Posted: Tue Apr 08, 2008 3:26 pm
by AlphaMeasure
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

Re: Displaying Merchant Fields in Order Email with nVelocity

Posted: Wed Apr 09, 2008 11:37 am
by sohaib
It should have worked. I will have a look at this in detail and see why it is not working.

Re: Displaying Merchant Fields in Order Email with nVelocity

Posted: Wed Apr 09, 2008 11:53 am
by Logan Rhodehamel
sohaib wrote:It should have worked. I will have a look at this in detail and see why it is not working.
I am wondering if we do not copy over merchant fields during the checkout process?

Re: Displaying Merchant Fields in Order Email with nVelocity

Posted: Thu Apr 10, 2008 12:12 pm
by sohaib
The checkout code is copying over the merchant fields but somehow they are not associated to the order item objects.

This is currently under investigation. Naveed is on it.

Re: Displaying Merchant Fields in Order Email with nVelocity

Posted: Thu Apr 10, 2008 1:05 pm
by sohaib
A bug has been entered in bugzilla. Merchant fields are not getting copied over properly.

Re: Displaying Merchant Fields in Order Email with nVelocity

Posted: Mon Aug 31, 2009 2:15 pm
by Logan Rhodehamel
We all got a little confused on this one. The bug was entered and we "fixed" the problem, but actually the fix is not the right approach. Merchant based input fields should not be copied with the order data because they are not specific to the order. Merchant based fields are specific to the product. The correct nVelocity text would be:

#########################
# Corrected Syntax to List Merchant Fields
#########################
#foreach($fieldValue in $orderItem.Product.TemplateFields)
#set ($field = $fieldValue.InputField)
#if ($field.IsMerchantField)
<br /><b>$field.UserPrompt:</b> $fieldValue.InputValue
#end
#end