Product Custom Fields in Email
Product Custom Fields in Email
Is it possible to access ProductCustomFields through NVelocity for purposes of displaying in an email template?
Re: Product Custom Fields in Email
Yes possible do something like this
Code: Select all
$product.CustomFields["CustomFieldName"].FieldValue
Re: Product Custom Fields in Email
Sorry Mazhar, I can't quite seem to get it.
What I tried was:
And this is the output:
CommerceBuilder.Products.ProductCustomFieldCollection["Availability"].FieldValue
What I tried was:
Code: Select all
$orderItem.Product.CustomFields["Availability"].FieldValue
CommerceBuilder.Products.ProductCustomFieldCollection["Availability"].FieldValue
Re: Product Custom Fields in Email
EDIT MADE
Hmm give a try to this
or if each product has only single product custom field then
Hmm give a try to this
Code: Select all
$orderItem.Product.CustomFields.get_Item('Availability').FieldValue
Code: Select all
$orderItem.Product.CustomFields.get_Item(0).FieldValue
Re: Product Custom Fields in Email
The latter worked so it doesn't look like get_Item will work by passing in the FieldName. For now my products only have the 'availability' field, but in the future they may have more. In that case I guess it might be possible to loop through them and only display the ones I need.
Thanks for your help.
Thanks for your help.
Re: Product Custom Fields in Email
Mazhar,
I know I am resurrecting an old thread, but I found a bug with the solution. If the item doesn't have a custom field then the email generation crashes as the index is out of range.
I tried to check if( $orderItem.Product.CustomFields.get_item(0) != null) and encountered the error:
Encountered "null" at line 102, column 64.
Was expecting one of:
"[" ...
"(" ...
<STRING_LITERAL> ...
"true" ...
"false" ...
<NUMBER_LITERAL> ...
<IDENTIFIER> ...
"{" ...
"!" ...
;
What is the proper way to check to see if the collection is null?
I know I am resurrecting an old thread, but I found a bug with the solution. If the item doesn't have a custom field then the email generation crashes as the index is out of range.
I tried to check if( $orderItem.Product.CustomFields.get_item(0) != null) and encountered the error:
Encountered "null" at line 102, column 64.
Was expecting one of:
"[" ...
"(" ...
<STRING_LITERAL> ...
"true" ...
"false" ...
<NUMBER_LITERAL> ...
<IDENTIFIER> ...
"{" ...
"!" ...
;
What is the proper way to check to see if the collection is null?
Re: Product Custom Fields in Email
Try this one instead
Code: Select all
#if($orderItem.Product.CustomFields.Count > 0)
$orderItem.Product.CustomFields.get_Item(0).FieldValue
#end
Re: Product Custom Fields in Email
Bingo! thx.