Order notification message improvement

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 anos atrás
Includes order with order notifcation email message:
Including order subtotal,tax,shipping and totals to notification msg:

alter/change the following to the /libraries/Nop.Common/Messages/MessageManager.cs

Line 159 REPLACE HTML table with:

/// <summary>
/// Convert a collection to a HTML table
/// </summary>
/// <param name="table">Order product variant collection</param>
/// <param name="CusSubTotal">Subtotal order customer costr</param>
/// <param name="CusTaxTotal">Taxtotal customercost</param>
/// <param name="CusTotal">total customer cost</param>
/// <param name="CusShipTotal">Shipping customer cost</param>
/// <param name="LanguageID">Language identifier</param>
/// <param name="CusCurCode">customer Currency code</param>
/// <returns>HTML table of products</returns>
private static string ProductListToHtmlTable(OrderProductVariantCollection table, string CusSubTotal, string CusTaxTotal, string CusTotal, string CusShipTotal, int LanguageID, string CusCurCode)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("<table class=\"table\" border=\"0\" style=\"border:1px solid grey;padding:2px;border-collapse:collapse;\"><thead><tr>");

            sb.AppendLine("<th class=\"header\" style=\"text-align:left;\">" + LocalizationManager.GetLocaleResourceString("Order.ProductsGrid.Name", LanguageID) + "</th>");
            sb.AppendLine("<th class=\"header\" style=\"text-align:right;\">" + LocalizationManager.GetLocaleResourceString("Order.ProductsGrid.Quantity", LanguageID) + "</th>");
            sb.AppendLine("<th class=\"header\" style=\"text-align:right;\">" + LocalizationManager.GetLocaleResourceString("Order.ProductsGrid.Price", LanguageID) + "</th>");
            sb.AppendLine("</tr></thead><tbody>");

            for (int i = 0; i <= table.Count - 1; i++)
            {
                sb.AppendLine("<tr>");
                //TODO add attributes description table[i].AttributeDescription                
                sb.AppendLine("<td class=\"row\" style=\"text-align:left;\">" + table[i].ProductVariant.FullProductName + "</td>");
                sb.AppendLine("<td class=\"row\" style=\"text-align:right;\">" + table[i].Quantity + "</td>");
                 sb.AppendLine("<td class=\"row\" style=\"text-align:right;\">" + string.Format("{0} ({1})", table[i].PriceInCustomerCurrency.ToString("N"),CusCurCode ) + "</td>");
                sb.AppendLine("</tr>");              
            }
            sb.AppendLine("<tr><td style=\"text-align:right;border-top:1px solid grey;\" colspan=\"2\"><strong>" + LocalizationManager.GetLocaleResourceString("Order.Sub-Total", LanguageID) + "</strong></td> <td style=\"text-align:right;\"><strong>" + CusSubTotal + "</strong></td></tr>");
            sb.AppendLine("<tr><td style=\"text-align:right;\" colspan=\"2\"><strong>" + LocalizationManager.GetLocaleResourceString("Order.Tax", LanguageID) + "</strong></td> <td style=\"text-align:right;\"><strong>" + CusTaxTotal + "</strong></td></tr>");
            sb.AppendLine("<tr><td style=\"text-align:right;\" colspan=\"2\"><strong>" + LocalizationManager.GetLocaleResourceString("Order.Shipping", LanguageID) + "</strong></td> <td style=\"text-align:right;\"><strong>" + CusShipTotal + "</strong></td></tr>");
            sb.AppendLine("<tr><td style=\"text-align:right;border-bottom:1px solid grey;\" colspan=\"2\"><strong>" + LocalizationManager.GetLocaleResourceString("Order.OrderTotal", LanguageID) + "</strong></td> <td style=\"text-align:right;\"><strong>" + CusTotal + "</strong></td></tr>");
            sb.AppendLine("</tbody></table>");
            return sb.ToString();
}



Then line 840 ALTER/CHANGE:
tokens.Add("Order.Product(s)", ProductListToHtmlTable(order.OrderProductVariants,LanguageID));


TO:


string CusSubTotal = string.Format("{0} ({1})", order.OrderSubtotalInCustomerCurrency.ToString("N"), order.CustomerCurrencyCode);
string CusTaxTotal = string.Format("{0} ({1})", order.OrderTaxInCustomerCurrency.ToString("N"), order.CustomerCurrencyCode);
string CusTotal = string.Format("{0} ({1})", order.OrderTotalInCustomerCurrency.ToString("N"), order.CustomerCurrencyCode);
string CusShipTotal = string.Format("{0} ({1})", order.OrderShippingInCustomerCurrency.ToString("N"), order.CustomerCurrencyCode);
string CusCurCode = order.CustomerCurrencyCode;
tokens.Add("Order.Product(s)", ProductListToHtmlTable(order.OrderProductVariants, CusSubTotal, CusTaxTotal, CusTotal, CusShipTotal, LanguageID, CuscurCode));



then rebuild Nop.Common

In admin go to: Content Management > Templates > Message templates and alter OrderPlaced.CustomerNotification message and add

Order:
%Order.Product(s)%

to the message body.





Is there a option/setting to send email as html messages instead of plain text?
14 anos atrás
Can someone test this for me?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.