Custom Email based on User Group

  • Posts: 38
  • Thank you received: 0
9 years 5 months ago #182184

-- HikaShop version -- : 2.3.4
-- Joomla version -- : 3.3.3
-- PHP version -- : 5.4.35
-- Browser(s) name and version -- : Chrome

Client needs the order, once submitted to go to a specific email address first that is not his own. However, it needs to be set based on a product category (or associated user group) so it doesn't effect the rest of the site.

For example : Client (Company A) has his own client (Company B) that can have employees log in and order products that are personalized just for them. However, once they order, the purchasing manager of Company B needs an email sent so they can approve it while Company A still receives the notification since their email address is set up in the HikaShop configuration.


Any chance this can be done?

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

  • Posts: 81605
  • Thank you received: 13083
  • MODERATOR
9 years 5 months ago #182189

Hi,

It can be done with a small custom code addition of the order creation/status notification emails via the menu System>Emails:

<?php
$userGroups = JAccess::getGroupsByUser($data->customer->user_cms_id);
if(in_array(10,$userGroups)){
 $data->customer->user_email .= ',manage@companya.com'; //for users in the user group with the id 10
}elseif(in_array(12,$userGroups)){
 $data->customer->user_email .= ',manage@companyc.com'; //for users in the user group with the id 12
}
?>

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

  • Posts: 38
  • Thank you received: 0
9 years 4 months ago #183052

Where do I put the code? I put it in the preload section, at the bottom and now when I hit Finish on an order, it brings up a blank page, though the order is created.

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

  • Posts: 13201
  • Thank you received: 2322
9 years 4 months ago #183065

Hi,

Please set the error reporting level to "maximum" this will display the php error present in the blank page and give us more details on this error.

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

  • Posts: 38
  • Thank you received: 0
9 years 4 months ago #183238

Turning it on gave me a clue to what the error is and I fixed it, however, when I do submit the order (the email portion works) but I get this error on the page:

Warning: explode() expects parameter 2 to be string, array given in path/libraries/joomla/string/punycode.php on line 209

And a box pops up and says:

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

  • Posts: 81605
  • Thank you received: 13083
  • MODERATOR
9 years 4 months ago #183310

These are not errors from HikaShop.
For the first one, you can turn off the "error reporting" option of the Joomla configuration and that will remove it.
For the box popup up, I don't know where that comes from.

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

Time to create page: 0.061 seconds
Powered by Kunena Forum