|
Member
|
Fabien Calais
-
11/25/2010 9:06:31 AM
can i use invoice custom macro in ecommerce email templates?
Hi,
I read in the Kentico_ECommerce_guide.pdf the following : "For your invoice and e-mail templates, you can use a whole range of pre-defined and data macros as you can find them at CMSDesk -> Tools -> Ecommerce -> Configuration -> Invoice."
I try to use ##PRODUCTLIST## pre-defined macro in the E-commerce - Order status notification to customer email template and the macro has not been transformed.
In the email, I get ##PRODUCTLIST## in place of the list of the ordered products
|
|
|
Member
|
Fabien Calais
-
11/25/2010 11:32:20 AM
RE:can i use invoice custom macro in ecommerce email templates?
I answer to myself...
I found that to use in the ECommerce email template the macro describe for the Invoice, i have to write them like this :
Invoice : ##PRODUCTLIST## Email : {%PRODUCTLIST%}
Somebody know why?
Anyway, i have another problem These macro use somme css class (productlist,...) they are define in the CMSDesk.css file So in order to use it in the template u have to add thes styles to your template
enjoy...
|
|
|
Kentico Developer
|
kentico_helenag
-
11/26/2010 2:35:45 AM
RE:can i use invoice custom macro in ecommerce email templates?
Hello, 1. You can use "Pre-defined macros" for invoices and "Data macros" for e-mail templates. 2. You can re-write any stylesheet or create a custom macro which meets your requirements. Best regards, Helena Grulichova
|
|
|
Member
|
Fabien Calais
-
11/26/2010 7:58:58 AM
RE:can i use invoice custom macro in ecommerce email templates?
Thanks,
Is there a way to have the code of the pre-defined macros? to facilate the write of custom macro
|
|
|
Kentico Developer
|
kentico_helenag
-
11/26/2010 8:44:17 AM
RE:can i use invoice custom macro in ecommerce email templates?
Hello, the full code is in the source code which you can order for extra pay. However, the content of ProductList macro is generated by following method: CMS.Ecommerce.OrderInfoProvider.GetProductList
So you can re-write it by the CustomOrderInfoProvider. Best regards, Helena Grulichova
|
|
|
Member
|
Fabien Calais
-
11/30/2010 5:18:05 AM
RE:can i use invoice custom macro in ecommerce email templates?
And what about write a custom function to send email to the customer in my return page after payment I found how to write it but I dont know what object I have to set for the resolver in order to use the data macros like {%PRODUCTLIST%} here is the code of my function : 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); }
|
|
|
Kentico Developer
|
kentico_helenag
-
11/30/2010 5:45:31 AM
RE:can i use invoice custom macro in ecommerce email templates?
Hello, I am not sure if the macros are not resolved without SourceObject or you want to resolve it by your custom way. If you want to resolve it by yourself you can follow these instructions: How to send an email using the email templateBest regards, Helena Grulichova
|
|
|
Member
|
Fabien Calais
-
11/30/2010 7:25:38 AM
RE:can i use invoice custom macro in ecommerce email templates?
Thanks for the link But this sample code use custom macro I have to define myself
Or what I want is to use the data macros already defined for the ecommerce template like {%PRODUCTLIST%}
Let me explain you why I want to do this :
I use a custom payment gateway (MERCANET) I have an automatic response when the payment is completed with 3 principle cases - 00 => payment succeed - 17 => payment cancel - default => payment failed
I want to send an email to the customer for each case But I want for each case use a different email template in order to easy customize the html of the answer.
I know I can use a custom macro who switch the html depending of the case. But its too complicate to write the html in code and re-define each of the ecommerce macro i want to use (customer name, order date, products list, total price, taxe, shipping, shipping address, payment result)
It's why i try to write my own function to send these email
|
|
|
Kentico Developer
|
kentico_helenag
-
11/30/2010 8:02:54 AM
RE:can i use invoice custom macro in ecommerce email templates?
Hello, Could you please use code for resolver like: MacroResolver resolver = CreateEmailMacroResolver(cartObj); resolver.EncodeResolvedValues = true; resolver.EncodeSpecialMacros = false;
It should resolve the macros according to current cart context. I am still not sure if your current code does not resolve the macros or you want to change the code of standard macros. Best regards, Helena Grulichova
|
|
|
Member
|
Fabien Calais
-
11/30/2010 8:39:07 AM
RE:can i use invoice custom macro in ecommerce email templates?
Sorry, the answer is : my current code does not resolve the data macros like {%PRODUCTLIST%}
I tried the code you send me with the CreateEmailMacroResolver(cartObj); But i have an error : 'CMS.Ecommerce.OrderInfoProvider' does not have a CreateEmailMacroResolver definition
I use kenticoCMS 4.1
|
|
|
Member
|
Fabien Calais
-
11/30/2010 8:48:07 AM
RE:can i use invoice custom macro in ecommerce email templates?
i made mistake my version of KenticoCMS is the 4.0 and not the 4.1
|
|
|
Kentico Developer
|
kentico_helenag
-
11/30/2010 9:54:51 AM
RE:can i use invoice custom macro in ecommerce email templates?
Hello, you need to use the namespace CMSEcommerce: CMS.CMSEcommerce.OrderInfoProvider.CreateEmailMacroResolver
Best regards, Helena Grulichova
|
|
|
Member
|
Fabien Calais
-
11/30/2010 10:10:45 AM
RE:can i use invoice custom macro in ecommerce email templates?
It works ! :) Thanks a lot
|
|
|
Member
|
Fabien Calais
-
12/7/2010 5:22:06 AM
RE:can i use invoice custom macro in ecommerce email templates?
Hello, I be back with my problem... In fact, Your solution works for the html version of the email but when i check the plain text version, the macro is resolved but encoded can you help for the code ? here under my actual code EmailMessage message = new EmailMessage(); message.Subject = orderID.ToString(); message.Recipients = CustomerInfoProvider.GetCustomerInfo(order.OrderCustomerID).CustomerEmail; message.Body = template.TemplateText; message.PlainTextBody = template.TemplatePlainText;
MacroResolver resolver = CMS.CMSEcommerce.OrderInfoProvider.CreateEmailMacroResolver(si); resolver.EncodeResolvedValues = true; resolver.EncodeSpecialMacros = false;
EmailSender.SendEmailWithTemplateText(CMSContext.CurrentSiteName, message, template, resolver, true);
|
|
|
Kentico Developer
|
kentico_helenag
-
12/9/2010 5:58:10 AM
RE:can i use invoice custom macro in ecommerce email templates?
Hello, Could you please try to use: resolver.EncodeResolvedValues = false;
It should help. Best regards, Helena Grulichova
|
|