Different emails for different product categories

  • Posts: 7
  • Thank you received: 0
13 years 8 months ago #10966

Is it possible to send out different email notifications based on what the product or product category?

My client sells event tickets, apparel, and sponsorships -- and wants a different message sent out based on what the customer purchased.

Essentials is currently installed, and I will purchase Business if this is something that can be done.

Thank you again for your help -- this is such a great product!!

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
13 years 8 months ago #10971

Hi,

With the business edition, you will be able to edit the emails via the menu System->Emails.
There you will be able to write some PHP code to loop through the products in the order and decide to display your email in one way or another.

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

  • Posts: 7
  • Thank you received: 0
13 years 8 months ago #10973

Hi there,

Thanks for your quick reply! Your product and support are absolutely amazing.

Is the PHP code you speak of something simple that you could help me with, or would it require advanced PHP knowledge? I'm basically a PHP beginner, and would have no idea how to do what you described above.

Thanks again!

Last edit: 13 years 8 months ago by jaime815.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
13 years 8 months ago #10977

The code will depends on the email you want to edit.

If it's the order creation email where you have the summary of the order, you can just do something like this:
$product_found = false;
foreach($data->cart->products as $item){
if($item->order_product_code=="CODE_OF_MY_PRODUCT"){ $product_found = true; }
}
if($product_found){
//display something
}else{
//display something else
}

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

  • Posts: 7
  • Thank you received: 0
13 years 8 months ago #10979

Hi,

That sounds great thank you. :)

Just to clarify -- is there no way to do this with a product category, rather than an individual product code?

It occurred to me to do it the way you've shown, that the PHP would have to be edited every time my client creates a new product, because there will be a new product code. Is that correct? And the way my client's products will be organized, only one product from each category will be active at any given time, so I thought perhaps instead of changing the PHP for a product code, using the category would be easier.

Unfortunately, my client is extremely against editing code, but wants to edit & customize the entire site themselves -- catch 22!

I completely understand if this isn't readily possible, and again, the support is amazing!

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
13 years 8 months ago #10980

Everything is possible, as long as you know how to code it...

I gave you a simple version with the product code.
If you want to check the category id that's a bit more complex... You need something like this:
$db=&JFactory::getDBO();
$db->setQuery('SELECT product_id FROM '.hikashop::table('product_category').' WHERE category_id=XXX'); //you need to replace XXX with the id of your category
$products_in_category=$db->loadResultArray();
$product_found = false;
foreach($data->cart->products as $item){
if(in_array($item->order_product_id,$products_in_category)){ $product_found = true; }
}
if($product_found){
//display something
}else{
//display something else
}

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

Time to create page: 0.062 seconds
Powered by Kunena Forum