Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Email editing for Ecommerce websites View modes: 
User avatar
Certified Developer v7
Certified  Developer v7
Gitesh - 8/17/2011 12:40:58 AM
   
Email editing for Ecommerce websites
HI Guys,

I am editing the emails in CMSsitemanager> Development> Email template >E-commerce - Order notification to customer

I can see that product details are coming from the code {%PRODUCTLIST%}.

I want to remove the tax column from it.

How can I do so?

Thanks
Gitesh Shah

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 8/17/2011 4:57:26 AM
   
RE:Email editing for Ecommerce websites
Hi,

if you need to modify the value of a default macro, you can use a custom provider and change method:

string GetProductList(DataTable dt, object currency, bool renderDiscount)

More information you can find in article Customizing invoice templates.

Alternatively, you could use a custom macro a create your own product list - it is described in the middle of above article.

Best regards,
Ivana Tomanickova

User avatar
Certified Developer v7
Certified  Developer v7
Gitesh - 8/22/2011 7:02:32 PM
   
RE:Email editing for Ecommerce websites
HI Ivana,

Where can I find the code:
string GetProductList(DataTable dt, object currency, bool renderDiscount)

and also is it possible to edit the DataTable dt?
Do I need to edit the DLL file for that?

Thanks
Gitesh Shah

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 8/23/2011 6:07:45 AM
   
RE:Email editing for Ecommerce websites
Hi,

the code of method is a part of full source code so here is the original method:


/// <summary>
/// Returns html code that represents payment option. Used for generating of invoice.
/// </summary>
/// <param name="dt">Table with the order data</param>
/// <param name="currency">Currency info</param>
/// <param name="renderDiscount">Render discount values</param>
public static string GetProductList(DataTable dt, CurrencyInfo currency, bool renderDiscount)
{
if ((dt != null) && (dt.Rows.Count > 0))
{
StringBuilder sb = new StringBuilder();

// Header
sb.Append(" <table width=\"100%\" style=\"text-align: right\" cellspacing=\"0\" cellpadding=\"2\" class=\"productsList\">");
sb.Append(" <thead><tr><th colspan=\"" + (5 + (renderDiscount ? 1 : 0)) + "\" class=\"headerBorder\"> </th></tr><tr>");
sb.Append(" <th style=\"text-align: left;padding-left:2px\">");
sb.Append(ResHelper.GetString("InvoiceTemplate.SKUName"));
sb.Append(" </th>");
sb.Append(" <th>");
sb.Append(ResHelper.GetString("InvoiceTemplate.SKUUnits"));
sb.Append(" </th>");
sb.Append(" <th>");
sb.Append(ResHelper.GetString("InvoiceTemplate.SKUPrice"));
sb.Append(" </th>");
if (renderDiscount)
{
sb.Append(" <th>");
sb.Append(ResHelper.GetString("InvoiceTemplate.UnitDiscount"));
sb.Append(" </th>");
}
sb.Append(" <th>");
sb.Append(ResHelper.GetString("InvoiceTemplate.Tax"));
sb.Append(" </th>");
sb.Append(" <th>");
sb.Append(ResHelper.GetString("InvoiceTemplate.Subtotal"));
sb.Append(" </th>");
sb.Append("</tr></thead><tbody>");

double value = 0.0;

// Add the items
foreach (DataRow dr in dt.Rows)
{
string name = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(Convert.ToString(DataHelper.GetDataRowValue(dr, "SKUName"))));

// If it is a product option
if (ValidationHelper.GetGuid(DataHelper.GetDataRowValue(dr, "CartItemParentGuid"), Guid.Empty) != Guid.Empty)
{
name = "  - " + name;
}

sb.Append("<tr>");
sb.Append(" <td style=\"text-align: left\">");
sb.Append(name);
sb.Append(" </td>");
sb.Append(" <td>");
sb.Append(Convert.ToString(DataHelper.GetDataRowValue(dr, "SKUUnits")));
sb.Append(" </td>");
sb.Append(" <td>");
value = ValidationHelper.GetDouble(DataHelper.GetDataRowValue(dr, "SKUPrice"), 0);
sb.Append(Ecommerce.CurrencyInfoProvider.GetFormatedValue(value, currency));
sb.Append(" </td>");
if (renderDiscount)
{
sb.Append(" <td>");
value = ValidationHelper.GetDouble(DataHelper.GetDataRowValue(dr, "UnitDiscount"), 0);
sb.Append(Ecommerce.CurrencyInfoProvider.GetFormatedValue(value, currency));
sb.Append(" </td>");
}
sb.Append(" <td>");
value = ValidationHelper.GetDouble(DataHelper.GetDataRowValue(dr, "Tax"), 0);
sb.Append(Ecommerce.CurrencyInfoProvider.GetFormatedValue(value, currency));
sb.Append(" </td>");
sb.Append(" <td>");
value = ValidationHelper.GetDouble(DataHelper.GetDataRowValue(dr, "Subtotal"), 0);
sb.Append(Ecommerce.CurrencyInfoProvider.GetFormatedValue(value, currency));
sb.Append(" </td>");
sb.Append("</tr>");
}
sb.Append(" <tr>");
sb.Append(" <td colspan=\"" + (5 + (renderDiscount ? 1 : 0)) + "\" class=\"bottomBorder\"> ");
sb.Append(" </td>");
sb.Append(" </tr>");
sb.Append(" </tbody>");
sb.Append("</table> \n");

return sb.ToString();
}
else
{
return null;
}
}



You can change the method to return requested html code. How to use custom providers is described here:
custom providers

Then you can overwrite the method in your custom order info provider.

Alternatively you could create a custom macro - that will return requested html code (example is in the middle of document):
http://devnet.kentico.com/docs/ecommerceguide/customizing_invoice_and_email_templates.htm

Best regards,
Ivana Tomanickova

User avatar
Certified Developer v7
Certified  Developer v7
Gitesh - 8/24/2011 12:33:27 AM
   
RE:Email editing for Ecommerce websites
Hi Ivana,

I think creating a custom macro would be easier. But I am not sure how to get the Product name.

If I create a Custom Macro, from which table can I grab information of product name?

E.g: %ProductList% - gives the whole product information in the same way what shall I write to get only the product name.

Thanks
Gitesh Shah




User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 8/24/2011 4:31:08 AM
   
RE:Email editing for Ecommerce websites
Hi.

here is a code example where you can see how to get information about product inserted in the shopping cart:


case "totalcredit":

match = true;
result = "";
// html tags will behave as tags, not text
sender.AllowParameters = false;

// Get shopping cart object from resolver
CMS.Ecommerce.ShoppingCartInfo cartObj = sender.SourceObject as CMS.Ecommerce.ShoppingCartInfo;

if ((cartObj != null) && (cartObj.ShoppingCartCustomerID > 0))
{
// in the al you can find all information - i.e. each shopping cart item and its name
ArrayList al = cartObj.CartItems;
// add data from al to result according to your needs
result = "<p> Here is my custom product list: </p>...";

}

break;


Best regards,
Ivana Tomanickova

User avatar
Member
Member
info-kentico-template - 12/14/2011 3:17:35 PM
   
RE:Email editing for Ecommerce websites
Hi,

This is exactly what I was looking for.

Could you please tell me in which file shall I make this change?

Thanks

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 12/15/2011 5:44:02 AM
   
RE:Email editing for Ecommerce websites
Hi,

you need to create a custom macro, how to do it in version 5.5 R2 is described here:
custom macro development

Best regards,
Ivana Tomanickova