[Feature] Ordered products in email

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 15 años
For the current project (that uses nopCommerce) I need to forward the order from the customer to the manufacturer so he can handle the delivery. Every thing seems easy enough just forward the email with the order received from the customer to the manufacturer, but in the mail template you don't have the products the customer ordered so you'd need to add them manually in the email. So I've added a new method to the NopSolutions.NopCommerce.Common.Messages.MessageManager called ListToHtmlTable
/// <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)%
Hace 15 años
Nice one jkr,

This is just what I was referring to in http://forums.nopcommerce.com/forums/default.aspx?g=posts&t=233

Product information should definitely be included on the Storekeeper notifications in the next release.

Cheers,
Ben
Hace 15 años
Does anyone know how i can get the taxcountry.Percentage in there

I tried using:



decimal TaxPercentage = GetTaxPercentage(order.BillingCountryID);


public static decimal GetTaxPercentage(int BCountryId)
        {
            decimal sTax = 0;

            TaxByCountry taxByCountry = TaxByCountryManager.GetByTaxByCountryID(BCountryId);
            if (taxByCountry != null)
            {
                sTax = taxByCountry.Percentage;
            }

            return sTax;
        }



But it returns zero.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.