Page 1 of 1
Turning off order shipment email
Posted: Mon Apr 18, 2011 11:50 am
by freeweaver
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?
Re: Turning off order shipment email
Posted: Mon Apr 18, 2011 7:37 pm
by triplw
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.
Re: Turning off order shipment email
Posted: Tue Apr 19, 2011 11:08 am
by freeweaver
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();
}
}
Re: Turning off order shipment email
Posted: Tue Apr 19, 2011 11:47 am
by triplw
Looks good to me. What if you tried:
emailTemplates[0].ToAddress = _OrderShipment.Order.BillToEmail;
instead of
emailTemplates[0].ToAddress = _OrderShipment.Address.Email; ??
Re: Turning off order shipment email
Posted: Tue Apr 19, 2011 12:24 pm
by freeweaver
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.
Re: Turning off order shipment email
Posted: Wed Apr 20, 2011 5:31 am
by mazhar
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.
Re: Turning off order shipment email
Posted: Wed Apr 20, 2011 9:06 am
by freeweaver
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();
}
}