Page 1 of 1

Sending Different Emails based on the Payment Type

Posted: Tue Aug 06, 2013 9:48 am
by hiteshsingla
I am using Broadleaf Commerce 2.2.0-GA
I just want to confirm that is there any way around in the core that sends two different mail templates based on the Payment type.Like if the Payment is made using Credit card then a different template should go and if the payment is made using paypal that a different mail should go.
If this feature is not there in the core than can anyone please tell me any work-around for this??
Glad if anybody can help me out.

Thanks & Regards
Hitesh Singla

Re: Sending Different Emails based on the Payment Type

Posted: Tue Aug 06, 2013 10:48 am
by phillipuniverse
You can look at the order.getPaymentInfos() and then check the PaymentInfoType for the PaymentInfo (paymentInfo.getType()).

Re: Sending Different Emails based on the Payment Type

Posted: Wed Aug 07, 2013 2:57 am
by hiteshsingla
Thanks for the reply phillip!!
Where should i check this condition and where i do need to define that which template should be compiled?

I do get that I can check the type of payment using the method suggested by you but how can I define the name of the email template which should be used with respective payment type??

Thanks & Regards
Hitesh Singla

Re: Sending Different Emails based on the Payment Type

Posted: Wed Aug 07, 2013 10:03 am
by phillipuniverse
I was assuming that you would have an activity within the blCheckoutWorkflow that will check the payment info and then send an appropriate email. In this activity, I imagine that you will want to inject EmailService and send an email from there.

Re: Sending Different Emails based on the Payment Type

Posted: Mon Aug 12, 2013 9:35 am
by hiteshsingla
Thanks phillip!!
So in this I activity I will be injecting EmailService,then how can I override the properties of blOrderConfirmationMailInfo bean in the applicationContext-email.xml??
As in that bean template is defined for the order confirmation.
Hope I can get some help over this.

Thanks & Regards
Hitesh Singla

Re: Sending Different Emails based on the Payment Type

Posted: Mon Aug 12, 2013 12:24 pm
by elbertbautista
If you are using Broadleaf's OrderConfirmationController, see com.mycompany.controller.checkout.OrderConfirmationController
you can override the "sendConfirmationEmail" method to look at the appropriate payment method that was used on the order and send the correct MailInfo template to the EmailService

Re: Sending Different Emails based on the Payment Type

Posted: Sat Nov 23, 2013 12:46 am
by ZingZong707
How can I define the name of the email template which should be used with respective payment type?

Re: Sending Different Emails based on the Payment Type

Posted: Tue Jan 07, 2014 4:08 pm
by phillipuniverse
There are a ton of ways you could do this. One way could be to just have a static hash map of payment type -> email template in that controller. Another way could be to configure a map bean via XML and then inject it into where you need it.

Re: Sending Different Emails based on the Payment Type

Posted: Thu Oct 16, 2014 7:17 am
by rdokoye
That appears to be very helpful, I think another viable solution would be to integrate PayPal separately, I think that would give you even more freedom, although it would be very time consuming and longwinded.