trigger email for specific payment method?

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
crockettdunn
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 105
Joined: Sun Oct 26, 2008 6:32 pm
Contact:

trigger email for specific payment method?

Post by crockettdunn » Mon Mar 18, 2013 3:09 pm

My client needs notification emails sent for the case of purchases using a specific payment method (Purchase Orders) only.

The way I see it, my options are:
*custom trigger for this case
*use the normal, "order placed" trigger, with special email content (like order status or payment method) so that non-PO orders can be filtered on the server or by the email client
*Commandeer some sort of inventory/vendor-related event trigger to happen for PO orders, since my client is not tracking inventory (I'm getting creative).

Does anyone have experience with custom triggers for email templates?

Is the case still as it was in 2008, that I need to programmatically generate the email in the code where the 'trigger' event occurs, and custom triggers are not possible?

Kind regards,
Crockett

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: trigger email for specific payment method?

Post by mazhar » Tue Mar 19, 2013 3:26 am

crockettdunn wrote:Does anyone have experience with custom triggers for email templates?

Is the case still as it was in 2008, that I need to programmatically generate the email in the code where the 'trigger' event occurs, and custom triggers are not possible?
Yes you can't add any custom trigger and you will be needing to place code for email from where you want to trigger it. In your case since you only want to send Email for a specific payment method I think one way to do this could be to remove all triggers from order placed email template. Then you need to place code in OnePageCheckout.ascx.cs control's CheckedOut event handler. There you can decide depending upon payment method if you need to send email or not.

User avatar
crockettdunn
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 105
Joined: Sun Oct 26, 2008 6:32 pm
Contact:

Re: trigger email for specific payment method?

Post by crockettdunn » Tue Mar 19, 2013 10:51 am

Thanks, Mazhar! I'll give it a shot.

User avatar
crockettdunn
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 105
Joined: Sun Oct 26, 2008 6:32 pm
Contact:

Re: trigger email for specific payment method?

Post by crockettdunn » Wed Mar 20, 2013 9:34 am

Mazhar,
Is your suggestion to remove all triggers from the "order placed" email template un-related to the code (just to prevent duplicate emails for placing a PO order)?

I'm talking about a merchant notification only for PO orders, so I hope I can still have the customer email notifications for ALL orders as well.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: trigger email for specific payment method?

Post by mazhar » Wed Mar 20, 2013 10:20 am

Yes its not related to code I was thinking about duplicate orders.But since you just need it for merchant then I think you don't need it to remove all triggers. Custom Email code will simply send it to merchant email address in case of PO.

User avatar
crockettdunn
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 105
Joined: Sun Oct 26, 2008 6:32 pm
Contact:

Re: trigger email for specific payment method?

Post by crockettdunn » Wed Mar 20, 2013 11:00 am

Thanks. But I asked the wrong question (juggling too many things today!).

I'm wondering if I specify an EMAIL (under where it reads "select emails") on THIS screen:
Capture.PNG
Will changes be reflected on the Configure > Email > Templates page?

In other words we're using the same set of triggers and email templates for both?

User avatar
crockettdunn
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 105
Joined: Sun Oct 26, 2008 6:32 pm
Contact:

Re: trigger email for specific payment method?

Post by crockettdunn » Thu Mar 20, 2014 8:03 pm

Since I don't know how to write the code to trigger a special order status based on a specific payment method, I think the best I can do from a business process standpoint is to make a merchant order notification email with content that varies based on payment type. Then they can use their email system for flagging orders and routing to the appropriate personnel.

User avatar
crockettdunn
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 105
Joined: Sun Oct 26, 2008 6:32 pm
Contact:

Re: trigger email for specific payment method?

Post by crockettdunn » Thu Mar 20, 2014 8:07 pm

... but it would be better to programmatically set the order status, if anyone can point me in the right direction.

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: trigger email for specific payment method?

Post by jmestep » Fri Mar 21, 2014 5:00 am

This is not exactly what you want, but it was all I could find quickly. You can use this pattern, but you will have to experiment with it.

Code: Select all

 EmailTemplate template = EmailTemplateDataSource.Load(Token.Instance.Store.Settings.ProductTellAFriendEmailTemplateId);
                if (template != null)
                {
                    //STRIP HTML
                    Name.Text = StringHelper.StripHtml(Name.Text);
                    FromEmail.Text = StringHelper.StripHtml(FromEmail.Text);
                    FriendName.Text = StringHelper.StripHtml(FriendName.Text);
                    FriendEmail.Text = StringHelper.StripHtml(FriendEmail.Text);
                    // ADD PARAMETERS
                    template.Parameters["store"] = Token.Instance.Store;
                    template.Parameters["product"] = product;
                    template.Parameters["category"] = category;
                    template.Parameters["fromEmail"] = FromEmail.Text;
                    template.Parameters["fromName"] = Name.Text;
                    template.FromAddress = FromEmail.Text;
                    template.ToAddress = FriendEmail.Text;
                    template.Send();
                    FriendEmail.Text = string.Empty;
                    SentMessage.Visible = true;
                }
                else
                {
                    FailureMessage.Text = "Email template could not be loaded.";
                    FailureMessage.Visible = true;
                }
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

Post Reply