Custom fields in confirmations email

  • Posts: 18
  • Thank you received: 0
10 years 2 weeks ago #212273

-- HikaShop version -- : 2.5.0

How do I set extra custom fields to tabel address are also visible in the confirmation email.

Last edit: 9 years 11 months ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 84293
  • Thank you received: 13693
  • MODERATOR
10 years 1 week ago #212278

Hi,

To create custom address fields, you can go in the menu Display>Custom fields.
To have them display in your checkout, invoice, and emails, you want to edit the file "address_template" of both your backend and frontend template via the menu Display>Views and add the corresponding tag like for the other custom fields already there.

Last edit: 9 years 11 months ago by nicolas.
The following user(s) said Thank You: Webteur

Please Log in or Create an account to join the conversation.

  • Posts: 54
  • Thank you received: 1
  • Hikashop Business
9 years 11 months ago #213542

Two questions:

1. Will custom fields added to the User section show up in an address_template? I need my client's two user-based custom fields to appear on the Order confirmation email.

2. Can you edit the TITLE of the 1st and 2nds threads so that it says Custom fields instead of Custom Fileds? I almost didn't find this question in my search.

Thanks,

Toolie

Please Log in or Create an account to join the conversation.

  • Posts: 84293
  • Thank you received: 13693
  • MODERATOR
9 years 11 months ago #213586

Hi,

1. No, they won't display in addres_template. Only custom address fields will.
For custom user fields, you want to add such tag in the email HTML version when you edit your emails via the menu System>Emails:
{VAR:user.field_column}

2. I'll do that.

Please Log in or Create an account to join the conversation.

  • Posts: 54
  • Thank you received: 1
  • Hikashop Business
9 years 11 months ago #213752

I discovered that I do have a field in the Address table containing the certificate number. But I'm still having trouble getting it to show up. The field name is "licensecertnum" and from the placeholders I'm seeing in the HTML email, it looks like I need the following to get the field caption and the field contents to display within the emails.

{TXT:ADDRESS_LICENSECERTNUM}: {VAR:ADDRESS_LICENSECERTNUM}

Am I missing something?

Toolie

Please Log in or Create an account to join the conversation.

  • Posts: 84293
  • Thank you received: 13693
  • MODERATOR
9 years 11 months ago #213760

Hi,

For custom address fields, you need to edit the '"address_template" file for both your frontend and backend and you need to add a tag like the other address fields in that view file.
So if the column name is licensecertnum, the tag should be: {licensecertnum}

Please Log in or Create an account to join the conversation.

  • Posts: 54
  • Thank you received: 1
  • Hikashop Business
9 years 11 months ago #213825

Hi Nicolas, you'll notice that I followed the same capitalized placeholder model that I see in the HTML email code, but it didn't work, whether it was capitalized or not.

you need to edit the '"address_template" file

  • Are you talking about the HTML version of the email (as we were above) or a different file? If it's a different file, can you give me the path and filename?
  • I didn't capitalize the custom field, so it looks like you're telling me that I don't need the {VAR.user} prefix, but I can't be sure.

Please be as specific as possible. Thank you!

Toolie

Please Log in or Create an account to join the conversation.

  • Posts: 26272
  • Thank you received: 4044
  • MODERATOR
9 years 11 months ago #213843

Hi,

Nicolas was talking about the views and not the files (but the views are also files...)
So if you need to modify your address template : please edit the view for your front-end and your backend templates.

For the custom field, you have to keep the VAR if you want to access a variable set in the email preload.
Now if you are pointing to a custom field, you need to specify the good name and you need to use the right syntax.
Just like explained in the previous post : www.hikashop.com/forum/install-update/87...ns-email.html#213586
So please read carefully the previous Nicolas' replies ; you can forgot the last one where he made some typo mistakes but your answer are already there in the previous messages.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 54
  • Thank you received: 1
  • Hikashop Business
9 years 11 months ago #213969

Just so you know, Jerome, you're speaking to someone who as a professional technical writer has written Developer-level documentation for Microsoft and Amazon. I'm used to figuring things out, so if I am confused, other people reading this will be also. I'm thinking of their needs, not just my own.

The salient point left out here is WHERE one edits the address_template. The correct answer is:

1. In Hikashop, click the Display menu, then Views.
2. Select template you use for your web from the middle dropdown "All templates". That filters the available views for your particular template.
3. Click on address_template to open the editor.
4. Insert the fieldname surrounded by curly braces at the location where you want the data to appear. Click Save and Close to save your work.

OK, that takes care of adding the field in the address_template (which subsequently appears on emails, invoices, etc), but it still doesn't help me with getting the custom fields into the invoice email. I still don't have a clear answer on how to include the custom fields.


In looking at the Preload file, I see a variable called
$customer
that appears to contain all of the customer data.
$customer = $data->customer;

Elsewhere I see things like:
$customer_name = @$customer->name;

Which leads me to believe that if I need to pull up the 2 User Custom Fields (licensetype and licensenum), I should add variables to this array:
$vars = array(
	'LIVE_SITE' => HIKASHOP_LIVE,
	'URL' => $order_url,
	'order' => $data->cart,
	'ORDER_PRODUCT_CODE' => (bool)$config->get('show_product_code', false),
	'user' => $customer,
	'billing_address' => @$data->cart->billing_address,
	'shipping_address' => @$data->cart->shipping_address,
        'customer_licentype' = @$customer->licensetype,
	'customer_licennum' = @$customer->licensenum,	
	);

Am I on the right track to include these custom fields at this level? If not, what should the code be?

I tried adding the custom field placeholders {field_name} in Configuration | Emails | Order notification | HTML Email in the HTML email as {user.licensenum} and {user.licensetype} and Hikashop simply throws away the code and doesn't display anything. This procedure is not documented, and I'm beyond frustrated.

Can you advise?
Toolie

Last edit: 9 years 11 months ago by toolie.

Please Log in or Create an account to join the conversation.

  • Posts: 84293
  • Thank you received: 13693
  • MODERATOR
9 years 11 months ago #213985

Hi,

There is no need to modify the preload code of the email.
You can just use such tag in the HTML version of the email:
{VAR:user.licensenum}
if your custom user field's column name is licensenum
That's what I explained four days ago already: www.hikashop.com/forum/install-update/87...ns-email.html#213586

The tag format to use between the email HTML version and the address_template view file are not related to each other as one is an email and the other is a view file. The format is {field_name} in address_template for custom address fields, and {VAR:user.field_name} in the HTML version of the emails for custom user fields.

Please Log in or Create an account to join the conversation.

Time to create page: 0.080 seconds
Powered by Kunena Forum