Support forumCategory: QuestionsDifferent email notification for different service
james_giatas asked 2 years ago

Hello ,
I just purchased the connect extension.
Currently i have a free service and a paid one.
I need to have different email notification for each one.
Is there any filter or hook that i can use to create a different email for my second service? I’m a developer so i can customize it if you tell me which part of the code should be edited.
Thank you

3 Answers
Nikola Loncar Staff answered 2 years ago

Hi, there is a hook but it does not contain appointment info so you will not be able to make difference between services. We will add it asap so it will be part of new release. This will be temp solution for you, at some point we will add template engine to that mail notifications so you would be able to do something like this in template:

{if service == 2} Show one thing {endif} ...

Best regards,
Nikola

Nikola Loncar Staff answered 2 years ago

Hi, in latest version there are some improvements for that. So you can use hook ea_customer_mail_template, there are three params that you will receive:
$body_template, $app_array, $params

Best regards,
Nikola

Cameron JP replied 2 years ago

Hello Nikola,

I am looking to implement this.
I have managed to access and edit the $body_template, but I cant seem to pull the Service to compare its value in an If statement.

Would you be able to provide what I need to me the line of code so I can use service.:

if (service == 2) { Show one thing } else { Show other thing}.

Regards,
Cameron

mater replied 2 years ago

Hello Nikola,
I just bought “Extension 2 Year Updates” is it possible to use support + servise to help me with implematation this feature. I can probably pay extra money. I am just starting with PHP code and this tast is ower beyond my power. It is for good things we are using Easy Appointments for booking Korona vacination. I need to send diferent instruction for people booking for AstraZeneca and for Pfizer.

Thank you in advance.

Regads
Martin

Nikola Loncar Staff replied 2 years ago

Hi Martin, if you are willing to invest some money we can ship that feature fast. 🙂

Best regards,
Nikola

Cameron JP replied 2 years ago

Nikola,

This is somehting that I am looking to start using shortly. Do you have a contact e-mail in which we could discuss implementing this feature?

Many Thanks,
Cameron

Cameron JP answered 2 years ago

Incase anyone else needs the solution, I managed to work it out this morning. This may not the best way to get it working.
Created a new plugin just for this functionality.
In that plugin’s .php create a new function:
function service_specific_email($body_template, $app_array, $params) {
$service = $params['#service#'];
if ($service == 1) {
$body_service = "Thank you ...";
} elseif ($service == 2) {
$body_service = "Thank you for";
} else {
$body_service = "Thank you for ...";
}

$newBody = $body_service . $body_template;

return ($newBody);
}

add_filter('ea_customer_mail_template', 'service_specific_email', 10, 3);

 
Hope this helps anyone else.

Nikola Loncar Staff replied 2 years ago

Hi we will add that template engine soon. But this will also get things done 🙂

Best regards,
Nikola

Cameron JP replied 2 years ago

To Note, this will interact with the cancellation message also, so I’ll be looking at fixing that. I’ll post my fix here when I do.

Thanks for your response Nikola.

Cameron JP replied 2 years ago

function service_specific_email($body_template, $app_array, $params) {
$service = $params[‘#service#’];
$status = $params[‘#status#’];
if ($status == “confirmed”) {
if ($service == 1) {
//rest of code
}
}