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

#   Custom Email based on Category ID

##

- **[ACMLLC](/forum/user/34241-acmllc "View ACMLLC's Profile")**
- [![ACMLLC's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/34241-acmllc "View ACMLLC's Profile") Topic Author
- [ Offline](/forum/user/34241-acmllc)

Less More

- Posts: 21
- Thank you received: 2
-
-

11 years 6 months ago [\#202091](#202091) by [ACMLLC](/forum/user/34241-acmllc "View ACMLLC's Profile")  *[Custom Email based on Category ID](/forum/27-checkout/877032-custom-email-based-on-category-id#202091 "-- HikaShop version -- : 2.4.0 -- Joomla version -- : 3.4.1 -- PHP version -- : 5.4.40 -- Browser(s) name and version -- : Firefox 38.0.1  Hello,  We using the Business edition and would like to have the Order Administrator Notification email sent to additional email addresses based upon the Category ID of the product sold.  We're not sure what data structure to make the checks on in the Preload of this email.  We would like to do something like the following, but would appreciate a correction for the reference ($item, $data, or $this with final subelement):  if ($this-&gt;element-&gt;category&#95;id == 'xx') {  } elseif ($this-&gt;element-&gt;category&#95;id == 'yy') {  } else {  }  Will this work in this admin notification email? Or do we need to reference $data or $item instead to access the category&#95;id?  And finally, is this the correct way to add an email address to the recipient list? Or do we have to add to the customer email instead (in the order creation email preload) using code such as:  $data-&gt;customer-&gt;user&#95;email .=  Thanks in advance for your answer.")* was created by *[ACMLLC](/forum/user/34241-acmllc "View ACMLLC's Profile")*

-- HikaShop version -- : 2.4.0
-- Joomla version -- : 3.4.1
-- PHP version -- : 5.4.40
-- Browser(s) name and version -- : Firefox 38.0.1

Hello,

We using the Business edition and would like to have the Order Administrator Notification email sent to additional email addresses based upon the Category ID of the product sold.

We're not sure what data structure to make the checks on in the Preload of this email.

We would like to do something like the following, but would appreciate a correction for the reference ($item, $data, or $this with final subelement):

if ($this-&gt;element-&gt;category_id == 'xx') {
$this-&gt;mailer-&gt;addBCC('addr1@domain.com');
} elseif ($this-&gt;element-&gt;category_id == 'yy') {
$this-&gt;mailer-&gt;addBCC('addr2@comain.com');
} else {
$this-&gt;mailer-&gt;addBCC('addr3@domain.com');
}

Will this work in this admin notification email? Or do we need to reference $data or $item instead to access the category_id?

And finally, is this the correct way to add an email address to the recipient list? Or do we have to add to the customer email instead (in the order creation email preload) using code such as:

$data-&gt;customer-&gt;user_email .= ',manage@companyc.com';

Thanks in advance for your answer.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg3NzAzMi1jdXN0b20tZW1haWwtYmFzZWQtb24tY2F0ZWdvcnktaWQ/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: 86587
- Thank you received: 14326
-
-

11 years 6 months ago [\#202103](#202103) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Custom Email based on Category ID](/forum/27-checkout/877032-custom-email-based-on-category-id#202103 "-- HikaShop version -- : 2.4.0 -- Joomla version -- : 3.4.1 -- PHP version -- : 5.4.40 -- Browser(s) name and version -- : Firefox 38.0.1  Hello,  We using the Business edition and would like to have the Order Administrator Notification email sent to additional email addresses based upon the Category ID of the product sold.  We're not sure what data structure to make the checks on in the Preload of this email.  We would like to do something like the following, but would appreciate a correction for the reference ($item, $data, or $this with final subelement):  if ($this-&gt;element-&gt;category&#95;id == 'xx') {  } elseif ($this-&gt;element-&gt;category&#95;id == 'yy') {  } else {  }  Will this work in this admin notification email? Or do we need to reference $data or $item instead to access the category&#95;id?  And finally, is this the correct way to add an email address to the recipient list? Or do we have to add to the customer email instead (in the order creation email preload) using code such as:  $data-&gt;customer-&gt;user&#95;email .=  Thanks in advance for your answer.")*

Hi,

There is no category_id in any variable of the email. So that would require to load the list of all the categories of all the products of the order with a MySQL query to the database and then do your checks on them.
And do you send that to all the email addresses of all the categories of all the products of the order ?
So your code won't be that simple...

A simpler alternative would be to use HikaMarket Multivendor, create one vendor for each email address and assign each vendor to his products. The vendors would then automatically be notified of the purchase of their products (and they wouldn't even see the other products of other vendors in the notifications).

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

- **[ACMLLC](/forum/user/34241-acmllc "View ACMLLC's Profile")**
- [![ACMLLC's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/34241-acmllc "View ACMLLC's Profile") Topic Author
- [ Offline](/forum/user/34241-acmllc)

Less More

- Posts: 21
- Thank you received: 2
-
-

11 years 6 months ago [\#202607](#202607) by [ACMLLC](/forum/user/34241-acmllc "View ACMLLC's Profile")  Replied by *[ACMLLC](/forum/user/34241-acmllc "View ACMLLC's Profile")* on topic *[Custom Email based on Category ID](/forum/27-checkout/877032-custom-email-based-on-category-id#202607 "-- HikaShop version -- : 2.4.0 -- Joomla version -- : 3.4.1 -- PHP version -- : 5.4.40 -- Browser(s) name and version -- : Firefox 38.0.1  Hello,  We using the Business edition and would like to have the Order Administrator Notification email sent to additional email addresses based upon the Category ID of the product sold.  We're not sure what data structure to make the checks on in the Preload of this email.  We would like to do something like the following, but would appreciate a correction for the reference ($item, $data, or $this with final subelement):  if ($this-&gt;element-&gt;category&#95;id == 'xx') {  } elseif ($this-&gt;element-&gt;category&#95;id == 'yy') {  } else {  }  Will this work in this admin notification email? Or do we need to reference $data or $item instead to access the category&#95;id?  And finally, is this the correct way to add an email address to the recipient list? Or do we have to add to the customer email instead (in the order creation email preload) using code such as:  $data-&gt;customer-&gt;user&#95;email .=  Thanks in advance for your answer.")*

Thanks for the info and recommendation. I see how complex this would get because of a mix of categories and products possibly being present in an order.

We ordered Multi-Vendor and look forward to using your existing integrated solutions!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg3NzAzMi1jdXN0b20tZW1haWwtYmFzZWQtb24tY2F0ZWdvcnktaWQ/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.050 seconds

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