And here is our version:
/// <summary>
/// Convert a collection to a HTML table
/// </summary>
/// <param name="order">Order</param>
/// <param name="LanguageID">Language identifier</param>
/// <returns>HTML table of products</returns>
private static string ProductListToHtmlTable(Order order, int LanguageID)
{
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.Price", 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.Total", LanguageID) + "</th>");
sb.AppendLine("</tr></thead><tbody>");
Language language = LanguageManager.GetLanguageByID(LanguageID);
if (language == null)
language = NopContext.Current.WorkingLanguage;
OrderProductVariantCollection table = order.OrderProductVariants;
for (int i = 0; i <= table.Count - 1; i++)
{
sb.AppendLine("<tr>");
sb.AppendLine("<td class=\"row\">" + table[i].ProductVariant.FullProductName);
if (!String.IsNullOrEmpty(table[i].AttributeDescription))
{
sb.AppendLine("<br />");
sb.AppendLine(table[i].AttributeDescription);
}
if (!String.IsNullOrEmpty(table[i].TextOption))
{
sb.AppendLine("<br />");
sb.AppendLine(table[i].TextOption);
}
sb.AppendLine("</td>");
string priceStr = string.Empty;
switch (order.CustomerTaxDisplayType)
{
case TaxDisplayTypeEnum.ExcludingTax:
priceStr = PriceHelper.FormatPrice(table[i].PriceExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, language, false);
break;
case TaxDisplayTypeEnum.IncludingTax:
priceStr = PriceHelper.FormatPrice(table[i].PriceInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, language, true);
break;
}
sb.AppendLine("<td class=\"row\">" + priceStr + "</td>");
sb.AppendLine("<td class=\"row\">" + table[i].Quantity + "</td>");
string priceTotalStr = string.Empty;
switch (order.CustomerTaxDisplayType)
{
case TaxDisplayTypeEnum.ExcludingTax:
priceTotalStr = PriceHelper.FormatPrice(table[i].PriceExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, language, false);
break;
case TaxDisplayTypeEnum.IncludingTax:
priceTotalStr = PriceHelper.FormatPrice(table[i].PriceInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, language, true);
break;
}
sb.AppendLine("<td class=\"row\">" + priceTotalStr + "</td>");
sb.AppendLine("</tr>");
}
sb.AppendLine("<br />");
//totals
string CusSubTotal = string.Empty;
string CusShipTotal = string.Empty;
string CusPaymentMethodAdditionalFee = string.Empty;
string CusTaxTotal = string.Empty;
string CusTotal = string.Empty;
switch (order.CustomerTaxDisplayType)
{
case TaxDisplayTypeEnum.ExcludingTax:
{
CusSubTotal = PriceHelper.FormatPrice(order.OrderSubtotalExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, language, false);
CusShipTotal = PriceHelper.FormatShippingPrice(order.OrderShippingExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, language, false);
CusPaymentMethodAdditionalFee = PriceHelper.FormatPaymentMethodAdditionalFee(order.PaymentMethodAdditionalFeeExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, language, false);
}
break;
case TaxDisplayTypeEnum.IncludingTax:
{
CusSubTotal = PriceHelper.FormatPrice(order.OrderSubtotalInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, language, true);
CusShipTotal = PriceHelper.FormatShippingPrice(order.OrderShippingInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, language, true);
CusPaymentMethodAdditionalFee = PriceHelper.FormatPaymentMethodAdditionalFee(order.PaymentMethodAdditionalFeeInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, language, true);
}
break;
}
bool dislayShipping = order.ShippingStatus != ShippingStatusEnum.ShippingNotRequired;
bool displayPaymentMethodFee = true;
if (order.PaymentMethodAdditionalFeeExclTaxInCustomerCurrency == decimal.Zero)
{
displayPaymentMethodFee = false;
}
bool displayTax = true;
if (TaxManager.HideTaxInOrderSummary && order.CustomerTaxDisplayType == TaxDisplayTypeEnum.IncludingTax)
{
displayTax = false;
}
else
{
if (order.OrderTax == 0 && TaxManager.HideZeroTax)
{
displayTax = false;
}
else
{
CusTaxTotal = string.Format("{0} ({1})", order.OrderTaxInCustomerCurrency.ToString("N"), order.CustomerCurrencyCode);
}
}
CusTotal = string.Format("{0} ({1})", order.OrderTotalInCustomerCurrency.ToString("N"), order.CustomerCurrencyCode);
sb.AppendLine("<tr><td style=\"text-align:right;\" colspan=\"2\"><strong>" + LocalizationManager.GetLocaleResourceString("Order.Sub-Total", LanguageID) + "</strong></td> <td style=\"text-align:right;\"><strong>" + CusSubTotal + "</strong></td></tr>");
if (dislayShipping)
{
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>");
}
if (displayTax)
{
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>");
}
if (displayPaymentMethodFee)
{
sb.AppendLine("<tr><td style=\"text-align:right;\" colspan=\"2\"><strong>" + LocalizationManager.GetLocaleResourceString("Order.PaymentMethodAdditionalFee", LanguageID) + "</strong></td> <td style=\"text-align:right;\"><strong>" + CusPaymentMethodAdditionalFee + "</strong></td></tr>");
}
sb.AppendLine("<tr><td style=\"text-align:right;\" 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();
}