Rules for Admin Order Notifiation E-mails

  • Posts: 38
  • Thank you received: 0
13 years 3 days ago #15558

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.

  • Posts: 81604
  • Thank you received: 13082
  • MODERATOR
13 years 3 days ago #15575

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 = 'This email address is being protected from spambots. You need JavaScript enabled to view it.';

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 = 'This email address is being protected from spambots. You need JavaScript enabled to view it.';
break;
case 'state_Texas_4307':
$data->customer->user_email = 'This email address is being protected from spambots. You need JavaScript enabled to view it.';
break;
default:
$data->customer->user_email = 'This email address is being protected from spambots. You need JavaScript enabled to view it.';
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.

  • Posts: 38
  • Thank you received: 0
13 years 3 days ago #15576

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.

  • Posts: 38
  • Thank you received: 0
13 years 3 days ago #15587

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.

  • Posts: 81604
  • Thank you received: 13082
  • MODERATOR
13 years 3 days ago #15597

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.

  • Posts: 38
  • Thank you received: 0
13 years 2 days ago #15640

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 = 'This email address is being protected from spambots. You need JavaScript enabled to view it.';
break;
case 'City 2':
$data->customer->user_email = 'This email address is being protected from spambots. You need JavaScript enabled to view it.';
break;
case 'City 3':
$data->customer->user_email = 'This email address is being protected from spambots. You need JavaScript enabled to view it.';
break;
default:
$data->customer->user_email = 'This email address is being protected from spambots. You need JavaScript enabled to view it.';
break;
}

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

  • Posts: 31
  • Thank you received: 1
11 years 7 months ago #64273

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: This email address is being protected from spambots. You need JavaScript enabled to view it., This email address is being protected from spambots. You need JavaScript enabled to view it., This email address is being protected from spambots. You need JavaScript enabled to view it.

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.

  • Posts: 81604
  • Thank you received: 13082
  • MODERATOR
11 years 7 months ago #64412

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.050 seconds
Powered by Kunena Forum