Customers name for Email

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 years ago
I want to address a customer by name in an email template. Dear %Customer.FirstName%, however, the Customers First Name is a Key Value in table GenericAttributes. Is this accessible and if so what is the correct syntax?
3 years ago
programmatically outside of the email template?  this is how it's done in the CustomerModelFactory:
_genericAttributeService.GetAttribute<string>(customer, NopCustomerDefaults.FirstNameAttribute)
3 years ago
I want to keep this simple so the clients can edit the templates. Any changes needs to be managed within the Message Template Body.
3 years ago
I guess I don't understand, you already have the %Customer.FirstName% token available in most templates, did you copy the template from one where %Customer.FirstName% was not available?  you can tap into the MessageTokensAddedEvent / EntityTokensAddedEvent and add it from an IConsumer
3 years ago
af1racing wrote:
I guess I don't understand, you already have the %Customer.FirstName% token available in the template


Oh do I! So, sorry to have wasted your time. I never tried that I merely used %Customer.FirstName% as an example.
3 years ago
You're not wasting my time, I enjoy the learning.  See my edit above as some templates may not have it.  

However, something like the OrderPlaced.CustomerNotification has all of these and more:

%Customer.Email%, %Customer.Username%, %Customer.FullName%, %Customer.FirstName%, %Customer.LastName%, %Customer.VatNumber%, %Customer.VatNumberStatus%, %Customer.CustomAttributes%, %Customer.PasswordRecoveryURL%, %Customer.AccountActivationURL%, %Customer.EmailRevalidationURL%
3 years ago
Running the test template failed when I entered the %Customer.FirstName% value insofar as it said it was sent but nothing arrived. That said the test form input form values are more restricted and the only name was username.

I had looked at the OrderPlaced.CustomerNotification template and saw %Order.BillingFirstName% %Order.BillingLastName% but nothing beginning with Customer
3 years ago
Interesting, what version nopCommerce?  Does your SendOrderPaidCustomerNotification method in the WorkFlowMessageService have this line?

_messageTokenProvider.AddCustomerTokens(commonTokens, order.Customer);


In 4.2, I have all of these available:


Allowed message tokens
                                
%Store.Name%, %Store.URL%, %Store.Email%, %Store.CompanyName%, %Store.CompanyAddress%, %Store.CompanyPhoneNumber%, %Store.CompanyVat%, %Facebook.URL%, %Twitter.URL%, %YouTube.URL%, %Customer.Email%, %Customer.Username%, %Customer.FullName%, %Customer.FirstName%, %Customer.LastName%, %Customer.VatNumber%, %Customer.VatNumberStatus%, %Customer.CustomAttributes%, %Customer.PasswordRecoveryURL%, %Customer.AccountActivationURL%, %Customer.EmailRevalidationURL%, %Wishlist.URLForCustomer%, %Order.OrderNumber%, %Order.CustomerFullName%, %Order.CustomerEmail%, %Order.BillingFirstName%, %Order.BillingLastName%, %Order.BillingPhoneNumber%, %Order.BillingEmail%, %Order.BillingFaxNumber%, %Order.BillingCompany%, %Order.BillingAddress1%, %Order.BillingAddress2%, %Order.BillingCity%, %Order.BillingCounty%, %Order.BillingStateProvince%, %Order.BillingZipPostalCode%, %Order.BillingCountry%, %Order.BillingCustomAttributes%, %Order.Shippable%, %Order.ShippingMethod%, %Order.ShippingFirstName%, %Order.ShippingLastName%, %Order.ShippingPhoneNumber%, %Order.ShippingEmail%, %Order.ShippingFaxNumber%, %Order.ShippingCompany%, %Order.ShippingAddress1%, %Order.ShippingAddress2%, %Order.ShippingCity%, %Order.ShippingCounty%, %Order.ShippingStateProvince%, %Order.ShippingZipPostalCode%, %Order.ShippingCountry%, %Order.ShippingCustomAttributes%, %Order.PaymentMethod%, %Order.VatNumber%, %Order.CustomValues%, %Order.Product(s)%, %Order.CreatedOn%, %Order.OrderURLForCustomer%, %Order.PickupInStore%, %Order.OrderId%



For conditional expressions use the token %if (your conditions) ... endif%
3 years ago
Thanks for listing all of those. I'm using 4.3 but cannot imagine such outputs will have changed. They may work in a live instance but not in trial because in trial it will only accept the inputs entered in the form.
3 years ago
The mail failure has been found in the logs. Nothing to do with those inputs. Furthermore, on entering marge field values the input form updates.
Error sending e-mail. An error occurred while attempting to establish an SSL or TLS connection.
I'm sure it must be right. Will examine why mail is failing tomorrow.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.