Page 1 of 1

Custom Customer Fields

Posted: Thu Mar 13, 2008 12:50 pm
by bha
I would like to display some of the custom customer fields in the shipment information of the shipping confirmation email.

The default shows variables like $orderItem.SKU, $orderItem.Name, etc... What variable would the custom fields be?

Thanks in advance!
Bruce.

Posted: Mon Mar 17, 2008 7:36 am
by sohaib
You mean custom fields you defined for products?

Here is how you can access them

Code: Select all

#foreach($customField in $orderItem.Product.CustomFields )
     
     $customField.FieldName   :  $customField.FieldValue </br>
    
#end

Thanks Sohai.

Posted: Mon Mar 17, 2008 9:09 am
by bha
The custom fields are customer fields I had defined in the Product Templates.

I made a modification to the customer notification email template to replace the $orderItem.Name with just the custom fields to see if it would work.

After entering a dummy order and putting some values in the custom fields on the order to ensure some values, the email notification just shows a blank in the description column. See script...

#foreach($orderItem in $order.Items.FilterByShipmentAndSort($shipment.OrderShipmentId))
#beforeall
<tr>
<td><strong>SKU</strong></td>
<td><strong>Description</strong></td>
<td><strong>Quantity</strong></td>
<td><strong>Price</strong></td>
</tr>
#each
#if ($orderItem.OrderItemType == "Product")
<tr>
<td>$orderItem.Sku</td>

<!-- <td>$orderItem.Name</td> -->

<td>
#foreach($customField in $orderItem.Product.CustomFields )
$customField.Name : $customField.Value </br>
#end
</td>


<td>$orderItem.Quantity</td>
<td>$orderItem.ExtendedPrice.ToString("C")</td>
</tr>
#end
#end


The Sku and Quantity fields are populated but not the custom fields. If you see the problem, please inform.

Thanks,
Bruce.

Posted: Mon Mar 17, 2008 9:19 am
by sohaib
please try $customField.FieldName and $customField.FieldValue instead of $customField.Name and $customField.Value

Posted: Mon Mar 17, 2008 9:56 am
by bha
Same result with

<td class="Email">
#foreach($customField in $orderItem.Product.CustomFields )
$customField.FieldName : $customField.FieldValue </br>
#end
</td>

Posted: Mon Mar 17, 2008 10:16 am
by sohaib
oops I am sorry. $oderItem.Product.CustomFields will return the custom fields defined not the user specified values for the custom fields.

This should work ... although I haven't tested this either.

Code: Select all

#foreach($customInput in $orderItem.Inputs)     
     $customInput.Name   :  $customInput.InputValue </br>   
#end 

Posted: Mon Mar 17, 2008 10:22 am
by bha
WooHoo. Spot on! That did it. Thank you!

Re: Custom Customer Fields

Posted: Wed Jul 16, 2008 10:33 am
by lab_n_chemicals
sohaib,

This question is not related to the topic but ...
How do I use the ac_CustomFields table?
I cannot find anyplace in admin where I can work with this table.

Re: Custom Customer Fields

Posted: Wed Jul 16, 2008 11:59 am
by jmestep
There isn't any place in the admin right now. Joe has an add-on on his site that adds them to the admin.

Re: Custom Customer Fields

Posted: Wed Jul 16, 2008 2:24 pm
by lab_n_chemicals
Thanks a bunch Judy.

Re: Custom Customer Fields

Posted: Wed Jul 16, 2008 9:09 pm
by AbleMods
Thanks for the plug Judy :)

My add-on works with ac_Products custom fields though. I could probably adapt it to the ac_CustomFields, but it's not something I've explored in-depth at this point.