Skip to main content

Rules for Admin Order Notifiation E-mails

More
15 years 4 months ago #15558 by joelstad
Hello Again!

Thanks to all the great support, I can now get the order summary on the admin notification e-mail and the details of the user submitting the order including the user's name, city and state.

What I'd like to do is customize the To: section of the e-mail so the notification goes to the representative for that area. For instance: We accept orders from anyone in any state. A customer places an order in California and I want a notification sent to the representative in California only. Right now I have an e-mail address on our mail server and that e-mail address automatically sends a copy of the message to reps in all 50 states.

Is there a way to do this?

Thanks in advance!

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

More
15 years 4 months ago #15575 by nicolas
Hi,

There is no option for that in HikaShop. However, you can add some code in the emails in order to send to the appropriate email address.
You can edit the emails of HikaShop via the menu System->Emails (in the business edition).
There, you should be able to add at the end of the HTML version the code:

<?php
$data->customer->user_email = 'name@email.com';

in order to send the email to a specific email.

But if you want to have different emails based on the state you can do like that:

<?php
switch($data->cart->shipping_address->address_state){
case 'state_California_4265':
$data->customer->user_email = 'california@email.com';
break;
case 'state_Texas_4307':
$data->customer->user_email = 'texas@email.com';
break;
default:
$data->customer->user_email = 'default@email.com';
break;
}

the states namekey can be found in the database in the table hikashop_zone. I've only put here two of them so that you can run some tests.

Note that this code is not tested...

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

More
15 years 4 months ago #15576 by joelstad
Thank you! I'll mess with it and see what I come up with.

--Joel

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

More
15 years 4 months ago #15587 by joelstad
ok, I don't want to change who gets the user confirmation e-mail, I want to change who gets the admin notification based on the state.

Is that possible?

Thanks in advance!

--Joel

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

More
15 years 4 months ago #15597 by nicolas
That code and explanation was for the order admin notification.
In the order admin notification the $data->customer->user_email is the email of the administrator, not the one of the customer.

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

More
15 years 4 months ago #15640 by joelstad
This is resolved, thanks!

I changed the check from shipping_address to billing_address as we don't actually ship any product and I changed the state to city and it worked perfectly.

The following code was added after the } and before the ?> in the admin_order_notification file.

switch($data->cart->billing_address->address_city){
case 'City 1':
$data->customer->user_email = 'nobody-0@noplace.com';
break;
case 'City 2':
$data->customer->user_email = 'nobody-1@noplace.com';
break;
case 'City 3':
$data->customer->user_email = 'nobody-2@noplace.com';
break;
default:
$data->customer->user_email = 'nobody-3@noplace.com';
break;
}

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

More
14 years 3 weeks ago #64273 by FRMYR
Regarding this topic ( www.hikashop.com/en/forum/4-how-to/15558...n-e-mails.html#15575 ), I have a situation where I need to send to multiple email recipients BUT individually.

Normally one would list all emails in configuration as: salespro@abc.com, order@abc.com, otheremail@abc.com

There's a limitation in my Cloud Printer where I will have to print/email ONE at a time...no commas, no BCC, no CC and certainly no TOs of multiple designation.

Please let me what your thoughts and suggestions.

Thanks!

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

More
14 years 3 weeks ago #64412 by nicolas
It would require to send yourself the email.
Suppose that you can use the mail function of PHP, you could do something like that:
$content_of_the_email = ob_get_contents();
switch($data->cart->billing_address->address_city){
case 'City 1':
mail( 'nobody-0@noplace.com','Subject of the email',$content_of_the_email);
break;
case 'City 2':
mail( 'nobody-1@noplace.com','Subject of the email',$content_of_the_email);
break;
case 'City 3':
mail( 'nobody-2@noplace.com','Subject of the email',$content_of_the_email);
break;
default:
mail( 'nobody-3@noplace.com','Subject of the email',$content_of_the_email);
break;
}

If you can't use the mail function, you'll have to send them with joomla mail functions.

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

Time to create page: 0.215 seconds
Powered by Kunena Forum