Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Setting ShoppingCart in the CMSContext View modes: 
User avatar
Member
Member
envisasoft - 1/20/2011 6:48:13 PM
   
Setting ShoppingCart in the CMSContext
I created a web part that replaces the entire stepped process of buying an item off a web site. Everything is fine except when the notification email is sent out. There are macros in the email template, but they are not resolving; everything is blank. Since the web part does all the work on the stepped process, I have had to manually send the notifications. I simply grab the email template then for the body i use:

CMSContext.CurrentResolver.ResolveMacros(orderTemplate.TemplateText, true);

Since there is no shopping cart in the current context nothing is resolving. I searched and could not find anything in the documentation or on DevNet as to how I can set the shopping cart of the current context.

Please advise.

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 2/7/2011 3:30:59 AM
   
RE:Setting ShoppingCart in the CMSContext
Hello,


You can use a code like:

int orderID = Convert.ToInt32(Request.QueryString["order_id"]);
OrderInfo order = OrderInfoProvider.GetOrderInfo(orderID);
if (order != null)
{
ShoppingCartInfo si = ShoppingCartInfoProvider.GetShoppingCartInfoFromOrder(order.OrderID);
EmailTemplateInfo template = EmailTemplateProvider.GetEmailTemplate("Ecommerce.OrderPaymentNotificationToCustomer", CMSContext.CurrentSite.SiteName);
EmailMessage message = new EmailMessage();
message.Subject = "Ticket4U - Betalingsbevestiging E-Ticket - " + orderID.ToString();
message.Recipients = CustomerInfoProvider.GetCustomerInfo(order.OrderCustomerID).CustomerEmail;
CMS.GlobalHelper.MacroResolver resolver = new CMS.GlobalHelper.MacroResolver();
resolver.SourceObject = si;
resolver.ResolveMacros(message.Body);
EmailSender.SendEmailWithTemplateText(CMSContext.CurrentSiteName, message, template, resolver, true);
}


Please see this forum thread for more details: http://devnet.kentico.com/Forums.aspx?forumid=36&threadid=17443

I hope it will help.


Best regards,
Helena Grulichova