/// <summary>
/// Convert a collection to a HTML table
/// </summary>
/// <param name="table"></param>
/// <returns>String</returns>
public static string ListToHtmlTable(OrderProductVariantCollection table)
{
//localization
NopSolutions.NopCommerce.Common.Directory.Language language = NopContext.Current.WorkingLanguage;
//table builder
StringBuilder sb = new StringBuilder();
sb.AppendLine("<table class=\"table\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><thead><tr>");
sb.AppendLine("<th class=\"header\">" + NopSolutions.NopCommerce.Common.Localization.LocalizationManager.GetLocaleResourceString("Order.ProductsGrid.Name", language.LanguageID) + "</th>");
sb.AppendLine("<th class=\"header\">" + NopSolutions.NopCommerce.Common.Localization.LocalizationManager.GetLocaleResourceString("Order.ProductsGrid.Quantity", language.LanguageID) + "</th>");
sb.AppendLine("<th class=\"header\">" + NopSolutions.NopCommerce.Common.Localization.LocalizationManager.GetLocaleResourceString("Order.ProductsGrid.Price", language.LanguageID) + "</th>");
sb.AppendLine("</tr></thead><tbody>");
for (int i = 0; i <= table.Count - 1; i++)
{
sb.AppendLine("<tr>");
sb.AppendLine("<td class=\"row\">" + table[i].ProductVariant.Product.Name + "(" + table[i].ProductVariant.ManufacturerPartNumber + ")</td>");
sb.AppendLine("<td class=\"row\">" + table[i].Quantity + "</td>");
sb.AppendLine("<td class=\"row\">" + table[i].PriceInCustomerCurrency + "</td>");
sb.AppendLine("</tr>");
}
sb.AppendLine("</tbody></table>");
return sb.ToString();
}
To call the method just add a line in public static string ReplaceMessageTemplateTokens(Order order, string Template) method
tokens.Add("Order.Product(s)", ListToHtmlTable(order.OrderProductVariants));
and for each mail template that notifies the customer or admin add
%Order.Product(s)%