Turning off order shipment email

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
freeweaver
Ensign (ENS)
Ensign (ENS)
Posts: 8
Joined: Mon Apr 18, 2011 11:46 am

Turning off order shipment email

Post by freeweaver » Mon Apr 18, 2011 11:50 am

I'm trying to enter and order shipment without sending off email notification.
I added a checkbox to let a user choose whether to send notification and I'm able to skip over the part where I manually build an email, but I find later on, a call to OrderDataSource.Load send a shipment notification email anyway.
Is there a way to stop that from happening?

User avatar
triplw
Commander (CMDR)
Commander (CMDR)
Posts: 144
Joined: Sat Jan 12, 2008 5:34 pm
Contact:

Re: Turning off order shipment email

Post by triplw » Mon Apr 18, 2011 7:37 pm

Go to Admin > Configure > Email > Templates and click the edit icon for the Customer Order Notification template. Then click the the Event Triggers tab to uncheck the triggers that you don't want.

User avatar
freeweaver
Ensign (ENS)
Ensign (ENS)
Posts: 8
Joined: Mon Apr 18, 2011 11:46 am

Re: Turning off order shipment email

Post by freeweaver » Tue Apr 19, 2011 11:08 am

That stopped the automatic email from sending, but when I explicitly call the email send it doesn't send anymore.
Here's the code snippet. When the condition is true, I don't get the email:

Code: Select all

 if (SendNotificationCheckbox.Checked)
                {
                    EmailTemplateCollection emailTemplates = null;
                    if (!isPartial)
                    {
                        emailTemplates = EmailTemplateDataSource.LoadForCriteria(" Name = 'Order Shipped' ");
                    }
                    else
                    {
                        emailTemplates = EmailTemplateDataSource.LoadForCriteria(" Name = 'Order Shipped Partial' ");

                    }
                    if (emailTemplates != null && emailTemplates.Count > 0)
                    {
                        emailTemplates[0].Parameters.Add("store", _OrderShipment.Order.Store);
                        emailTemplates[0].Parameters.Add("customer", _OrderShipment.Order.User);
                        emailTemplates[0].Parameters.Add("order", _OrderShipment.Order);
                        emailTemplates[0].Parameters.Add("payments", _OrderShipment.Order.Payments);
                        emailTemplates[0].ToAddress = _OrderShipment.Address.Email;

                        emailTemplates[0].Send();
                    }
                }

User avatar
triplw
Commander (CMDR)
Commander (CMDR)
Posts: 144
Joined: Sat Jan 12, 2008 5:34 pm
Contact:

Re: Turning off order shipment email

Post by triplw » Tue Apr 19, 2011 11:47 am

Looks good to me. What if you tried:
emailTemplates[0].ToAddress = _OrderShipment.Order.BillToEmail;
instead of
emailTemplates[0].ToAddress = _OrderShipment.Address.Email; ??

User avatar
freeweaver
Ensign (ENS)
Ensign (ENS)
Posts: 8
Joined: Mon Apr 18, 2011 11:46 am

Re: Turning off order shipment email

Post by freeweaver » Tue Apr 19, 2011 12:24 pm

That definitely fixed the immediate problem, kind of, but here's the weird part:
If I go through the process in order manager as a new user, that initial email field is populated.
If I initially choose an existing user to create that order, that initial email field is not populated and I have to roll over to the Order.BillToEmail.
Any idea why that is? I'm working on tracking it down right now.

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

Re: Turning off order shipment email

Post by mazhar » Wed Apr 20, 2011 5:31 am

freeweaver wrote:That definitely fixed the immediate problem, kind of, but here's the weird part:
If I go through the process in order manager as a new user, that initial email field is populated.
If I initially choose an existing user to create that order, that initial email field is not populated and I have to roll over to the Order.BillToEmail.
Any idea why that is? I'm working on tracking it down right now.
Can you please explain it again? Specially this par "roll over to the Order.BillToEmail". It would be better if you provide some details about how to produce the case and what are you expecting the output to be.

User avatar
freeweaver
Ensign (ENS)
Ensign (ENS)
Posts: 8
Joined: Mon Apr 18, 2011 11:46 am

Re: Turning off order shipment email

Post by freeweaver » Wed Apr 20, 2011 9:06 am

In my code sample above, I mentioned I'm looking for the OrderShipment.Address.Email.
When I place an order as a new, unregistered user, there's a value in that field.
When I place an order as an existing, registered user, there isn't, and I'm not sure why. I'm expecting a value to be in that field no matter what.
I'm wondering why it isn't there.

Code: Select all

    if (SendNotificationCheckbox.Checked)
                    {
                        EmailTemplateCollection emailTemplates = null;
                        if (!isPartial)
                        {
                            emailTemplates = EmailTemplateDataSource.LoadForCriteria(" Name = 'Order Shipped' ");
                        }
                        else
                        {
                            emailTemplates = EmailTemplateDataSource.LoadForCriteria(" Name = 'Order Shipped Partial' ");

                        }
                        if (emailTemplates != null && emailTemplates.Count > 0)
                        {
                            emailTemplates[0].Parameters.Add("store", _OrderShipment.Order.Store);
                            emailTemplates[0].Parameters.Add("customer", _OrderShipment.Order.User);
                            emailTemplates[0].Parameters.Add("order", _OrderShipment.Order);
                            emailTemplates[0].Parameters.Add("payments", _OrderShipment.Order.Payments);
                            emailTemplates[0].ToAddress = _OrderShipment.Address.Email;

                            emailTemplates[0].Send();
                        }
                    }

Post Reply