Skip to main content

Adding custom order field to emails

More
12 years 5 hours ago #174425 by cnc
-- HikaShop version -- : 2.3.3
-- Joomla version -- : 2.5.27

Hi
All new to this and learning as I go.
I have created a custom text field called "activation_code" to the orders table which I want to use to enter and send a code to the customer after I have received payment in the confirmed/shipping email to the customer. I have read various topics in the board but still rather confused which system>> email to modify as I tried adding the following

<p style="border-bottom:1px solid #ddd;padding-bottom:10px;">
{VAR:ACTIVATION_CODE}
</p>
and before the line
<!--{ENDIF:ORDER_SUMMARY}-->
into the status notification email just after the section on "additional text" but the information did not show in the email.

Would someone please give me some simple instructions to how to achieve this. Thanks

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

More
11 years 11 months ago #174436 by Jerome
Hi,

What do you means with "custom text field" ?
{VAR:ACTIVATION_CODE} will display the variable ACTIVATION_CODE that you have to create in the email preload.
If you want to display an element from the order, the product or the item ; you have to use
Code:
{VAR:order.my_order_custom_field} {LINEVAR:product.my_product_custom_field} {LINEVAR:item.my_item_custom_field}
Regards,

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

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

More
11 years 11 months ago #174555 by cnc
I mean that I went to Display menu in Hikashop and then choose custom field from the drop down menu and then created a new custom field called activation_code of type text in the orders table.

what is the difference between LINEVAR and VAR?

so in the email preload box for the status notification email I type in {VAR:order.activiation_code} and the activation code will now appear in the email message?

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

More
11 years 11 months ago #174595 by Xavier
Hi,

You have to use this tag in the html part of the email, not in the preload one.

The difference between var and linevar is that var display one value, there is only one value for the activation code in the order, but for the product or item custom fields, as there is possibly many products in the order we use linevar to display the value for each products.

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

More
11 years 11 months ago #174700 by cnc
So what do I put in the pre-load part?

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

More
11 years 11 months ago #174611 by nicolas
Hi,

There is nothing to put in the preload for these tags to work. The are already handled by the preload.

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

More
11 years 11 months ago #174762 by cnc
I added {VAR:order.activiation_code} into the html part and nothing is showing in the email when i press the email button after going into the order and adding the activation code number

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

More
11 years 11 months ago #174781 by Jerome
Hi,

Did you put the code in the email "order notification" ?
This email is used when you click on on the "email" button in the backend.

I personally re-test the feature using an order custom field and the content {VAR:order.my_order_custom_field} and I displayed the content of my text order custom field.

Regards,

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

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

More
11 years 11 months ago #174851 by cnc
Yes.
Finally, worked it out by putting it just in front of {TXT:ORDER_END_MESSAGE} in the html. I guess it did not show before as it was inside one of the conditional IF clauses.

Now I have worked that one out, the next question is there a way using Hikashop Business to have this linked to a specific product or category of products, e.g. software products or ticket for an event?

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

More
11 years 11 months ago #174854 by Jerome
Hi,

Link what, link how ?
Please provide more details.

Regards,

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

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

More
11 years 11 months ago #174923 by cnc
currently the activation code field appears in every order for every product. How do I get the activation code field (or any custom field) just to be shown for one specific product or even one category of products?

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

More
11 years 11 months ago #175162 by Jerome
Hi,

I see, you only want to display the field when this field is not empty. Right ?
The best at this moment is to add some code in the preload in order to create a "conditional" value you can would be able to use that in the email
Code:
<!--{IF:MY_ORDER_CUSTOM_FIELD}--> My order custom field: {VAR:order.my_order_custom_field} <!--{ENDIF:MY_ORDER_CUSTOM_FIELD}-->
To create that conditional variable, you have to add some code in the end of the "preload" in order to create the variable.
Code:
$vars['MY_ORDER_CUSTOM_FIELD'] = !empty($data->cart->my_order_custom_field);
Regards,

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

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

More
11 years 11 months ago - 11 years 11 months ago #175266 by cnc
That will do.
so at the end of the preload all I need to add is:
Code:
$vars['ACTIVATION_CODE'] = !empty($data->cart->activation_code);
and if there is a value in the activation_code field it will display and if not the field and its label will not show?
Last edit: 11 years 11 months ago by Jerome. Reason: [code] is nice !

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

More
11 years 11 months ago #175294 by Jerome
Hi,

I really don't know what I can answer you.
But if you have to paste some code in the forum, please use the "[ code ]" tag, it's better otherwise some elements between brackets won't be displayed in the forum.

Regards,

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

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

More
11 years 8 months ago - 11 years 8 months ago #185517 by KeithBlow
I'm trying to add a custom field too. What am I doing wrong?
Code:
<span style="font-weight: bold;">Cost Center Number:</span> {VAR:USER.COSTCENTERNUMBER}

Do I have to declare it in the Preload? If so how?
Last edit: 11 years 8 months ago by KeithBlow.

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

More
11 years 8 months ago #185555 by Jerome
Hi KeithBlow,

In which email do you want to add this line (order creation / order notification / ...) ?

Just to be sure, what kind of custom field is "COSTCENTERNUMBER" ?
Does his name is in uppercase ?

Regards,

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

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

More
11 years 8 months ago #185658 by KeithBlow
I want it sent to the admin so they can see the number.

I only put it in capitals because everything else was in capitals. The actually field uses lowercase.

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

More
11 years 8 months ago #185664 by Jerome
Hi,

So you need to edit the order_admin_notification preload and replace
Code:
'order' => $data->cart, 'billing_address' => @$data->cart->billing_address, 'shipping_address' => @$data->cart->shipping_address,
By
Code:
'order' => $data->cart, 'user' => $userInfos, 'billing_address' => @$data->cart->billing_address, 'shipping_address' => @$data->cart->shipping_address,
Then you will be able to use the tag
Code:
{VAR:user.mycustomfieldname}
in the HTML part in order to display the content of a user custom field.
If the custom field name is in lowercase, you have to write it in lowercase too.

In the mails, we generally use the variables in uppercase when it's a pre-compile data ; when we deal with HikaShop objects (like the order object, the addresses objects, etc) we decided to write the name in lowercase ; so we can see easily the difference in the mail content.

Regards,

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

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

More
11 years 7 months ago - 11 years 7 months ago #190111 by KeithBlow
While your solutions worked perfectly, it turns out this is not what I need, which is my fault.

I used the Purchase Order plugin to create a payment where customer's add their number to it. I changed the name of it to "Cost Center No" and all. How do I get THAT number on the admin email?

Edit
Nevermind, found the answer here: www.hikashop.com/forum/payment-methods/8...r-option.html#173352
Last edit: 11 years 7 months ago by KeithBlow.

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

Time to create page: 0.407 seconds
Powered by Kunena Forum