Email "admin notification" depending on category

  • Posts: 13
  • Thank you received: 0
13 years 1 month ago #28439

Hi!

Is it possible to send the admin notification on order creation to different email addresses depending on the categories the products of that order are in?
Or maybe any other filter I could use to achieve something like that?

Kind regards,
Simon

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

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
13 years 1 month ago #28462

Hi,

There is no option for that but it would be possible with some code customization of the email. If you know PHP, you can do that via the menu System->Emails in the Business edition.
You will have to first load the categories of the products in the order and then based on the categories, you can set the emails to which you want to send the email in the variable:
$data->customer->user_email = array('mail@company.com','mail2@company2.com');

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

  • Posts: 13
  • Thank you received: 0
13 years 1 month ago #28473

Thanks, that did the job.
For others to follow:
First I loaded the product class, then I iterated through the products in the order and loaded the category ids.
In these category ids I then searched for the desired id and if found I added a second email address.

$productClass = hikashop::get('class.product');
foreach ($data->cart->products as $product) {
    $categories = $productClass->getCategories($product->product_id);
    if (is_array($categories) && in_array($wantedCategoryId, $categories) {
        $data->customer->user_email[] = $secondaryEmail;
        break;
    }
}
Kind regards, Simon

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

Time to create page: 0.039 seconds
Powered by Kunena Forum