[Skip to main content](#vessel-content)

#   Multiple email addresses

##

- **[FM Supply](/forum/user/60580-fm-supply "View FM Supply's Profile")**
- [![FM Supply's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/60580-fm-supply "View FM Supply's Profile") Topic Author
- [ Offline](/forum/user/60580-fm-supply)

Less More

- Posts: 11
- Thank you received: 0
-
-

6 months 1 week ago [\#371810](#371810) by [FM Supply](/forum/user/60580-fm-supply "View FM Supply's Profile")  *[Multiple email addresses](/forum/35-orders-management/910504-multiple-email-addresses#371810 "-- HikaShop version -- : 6.4.1 -- Joomla version -- : 3.10.12 -- PHP version -- : 7.4.33  Hi, I have a question regarding order confirmation emails in HikaShop.  I want to keep the current order confirmation emails unchanged, but also send a copy of the order confirmation to an additional email address for specific locations only.  For example: Essex Norfolk Newport News  Orders placed from these three locations should also send a copy to another email. Is there a built-in way in HikaShop to conditionally add a CC/BCC recipient based on the selected location or customer group?")* was created by *[FM Supply](/forum/user/60580-fm-supply "View FM Supply's Profile")*

-- HikaShop version -- : 6.4.1
-- Joomla version -- : 3.10.12
-- PHP version -- : 7.4.33

Hi,
I have a question regarding order confirmation emails in HikaShop.

I want to keep the current order confirmation emails unchanged, but also send a copy of the order confirmation to an additional email address for specific locations only.

For example:
Essex
Norfolk
Newport News

Orders placed from these three locations should also send a copy to another email.
Is there a built-in way in HikaShop to conditionally add a CC/BCC recipient based on the selected location or customer group?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50LzkxMDUwNC1tdWx0aXBsZS1lbWFpbC1hZGRyZXNzZXM/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86541
- Thank you received: 14304
-
-

6 months 1 week ago [\#371814](#371814) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Multiple email addresses](/forum/35-orders-management/910504-multiple-email-addresses#371814 "-- HikaShop version -- : 6.4.1 -- Joomla version -- : 3.10.12 -- PHP version -- : 7.4.33  Hi, I have a question regarding order confirmation emails in HikaShop.  I want to keep the current order confirmation emails unchanged, but also send a copy of the order confirmation to an additional email address for specific locations only.  For example: Essex Norfolk Newport News  Orders placed from these three locations should also send a copy to another email. Is there a built-in way in HikaShop to conditionally add a CC/BCC recipient based on the selected location or customer group?")*

Hello,

The cleanest way to do this is a small custom HikaShop plugin (group "hikashop") that listens to the onBeforeMailSend event. That event fires for every email HikaShop sends out, gives you the full order context, and lets you add a CC or BCC on the fly without modifying any email template. The existing confirmation emails stay exactly as they are; you only ADD extra recipients on the orders that match your locations.

Plugin file (extra_recipients.php): Code:

&lt;?php defined('_JEXEC') or die('Restricted access'); class plgHikashopExtra_recipients extends JPlugin { public function onBeforeMailSend(&amp;$mail, &amp;$mailer) { // Only act on order creation notifications. This skips status-change // emails, account-creation emails, password resets, etc. if (empty($mail-&gt;mail_name)) return; if (!in_array($mail-&gt;mail_name, array( 'order_creation_notification', 'order_admin_notification'))) { return; } // The order object is in $mail-&gt;data for order-related emails. $order = isset($mail-&gt;data) ? $mail-&gt;data : null; if (empty($order) &#124;&#124; empty($order-&gt;shipping_address)) return; // Match on the shipping address. address_state usually holds the // state name or code, but you can also test address_city or // address_post_code if your "location" lives there. $state = isset($order-&gt;shipping_address-&gt;address_state) ? trim($order-&gt;shipping_address-&gt;address_state) : ''; $city = isset($order-&gt;shipping_address-&gt;address_city) ? trim($order-&gt;shipping_address-&gt;address_city) : ''; $locations = array('Essex', 'Norfolk'); $match = false; foreach ($locations as $loc) { if (strcasecmp($state, $loc) === 0 &#124;&#124; strcasecmp($city, $loc) === 0) { $match = true; break; } } if (!$match) return; // Add the extra recipient. Replace with the Newport News address. // Use addBCC if you don't want the customer to see it in the // headers; use addCC if you do. $mailer-&gt;addBCC('newport.news@example.com', 'Newport News'); } }

The matching plugin manifest (extra_recipients.xml) is a standard Joomla plugin descriptor with &lt;extension type="plugin" group="hikashop"&gt;. Zip the two files together and install it from Extensions &gt; Manage &gt; Install, then enable the plugin in Extensions &gt; Plugins.

A few notes:

If your "location" really lives in a different field, like a postcode prefix, the country code, a custom address field, etc you need to replace the $state / $city test with whatever you need. Every column of the address row is available on $order-&gt;shipping_address.

If you want different recipients per location (Essex -&gt; one address, Norfolk -&gt; another), turn the locations array into a map and pick the recipient per match instead of using a single addBCC at the end.

For the customer's copy (mail_name == 'order_creation_notification') vs the merchant's copy ('order_admin_notification'), you can decide which one(s) you want the extra recipient added to by tightening the in_array() above.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzM1LW9yZGVycy1tYW5hZ2VtZW50LzkxMDUwNC1tdWx0aXBsZS1lbWFpbC1hZGRyZXNzZXM/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.043 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
