Hello:
I just want to change the display of product details in ecommerce notification email.
The old display is:
Product Name Units Unit Price Tax Total Price
Product1 1 10.00 1.00 11.00
-Product1-option 1 2.00 0.20 2.20
I want to change it into:
Product Name Units Unit Price Tax Total Price
Product1 1 12.00 1.20 13.20
-Product1-option
I tried to follow document devnet.kentico.com/docs/6_0/ecommerceguide/customizing_invoice_and_email_templates.htm
But to be honest, I don't know how to do that. I'm confused where to put the code, in App_Code folder, create a new cs file, or something else? And how to register the custom macro? I also had a look of dev guid of macro expression, but I also don't know what to do. Is there anywhere that I can find a complete sample?
Then I tried to use custom marco method to achieve that.
The old macro in e-mail template is :ContentTable.ApplyTransformation(...);
I deleted it and change into my own macro:
{%OrderInfo(Order.OrderID)%}
but display nothing.
Below is my macro code:
MacroMethods.RegisterMethod("OrderInfo", OrderInfo, typeof(string), "Returns concatenation of two strings.", null, 1, new object[,] { { "param1", typeof(int), "1" } }, null);
public static string OrderInfo(int param1)
{
string result = "";
DataSet ds=OrderItemInfoProvider.GetOrderItems(param1);
DataTable dt= ds.Tables[0];
int index = 0;
for (int i = 0; i < dt.Rows.Count; i++)
{
if (dt.Rows["IsProductOption"].ToString() == "False")
{
index = i;
}
else
{
dt.Rows[index]["UnitPrice"] = (double.Parse(dt.Rows[index]["UnitPrice"].ToString()) + double.Parse(dt.Rows["UnitPrice"].ToString())).ToString();
dt.Rows[index]["TotalTax"] = (double.Parse(dt.Rows[index]["TotalTax"].ToString()) + double.Parse(dt.Rows["TotalTax"].ToString())).ToString();
dt.Rows[index]["TotalPrice"] = (double.Parse(dt.Rows[index]["TotalPrice"].ToString()) + double.Parse(dt.Rows["TotalPrice"].ToString())).ToString();
dt.Rows["UnitPrice"] = 0;
dt.Rows["TotalTax"] = 0;
dt.Rows["TotalPrice"] = 0;
}
}
for (int i = 0; i < dt.Rows.Count; i++)
{
if (dt.Rows["IsProductOption"].ToString() == "False")
{
result+="<tr>";
result+="<td style=\"text-align: left\">"+dt.Rows["SKUName"].ToString();
result+="</td>";
result+="<td>"+dt.Rows["Units"]+"</td>";
result+="<td>"+dt.Rows["UnitPrice"]+"</td>";
result+="<td>"+dt.Rows["TotalTax"]+"</td>";
result+="<td>"+dt.Rows["TotalPrice"]+"</td>";
result+="</tr>";
}
else
{
result+="<tr>";
result+="<td style=\"text-align: left\"> -"+dt.Rows["SKUName"].ToString();
result+="</td>";
result+="</tr>";
}
}
return result;
}
public static object OrderInfo(params object[] parameters)
{
switch (parameters.Length)
{
case 1:
// Overload with one parameter
return OrderInfo(ValidationHelper.GetInteger(parameters[0], 0));
default:
// No other overload is supported
throw new NotSupportedException();
}
}
CustomMacroMethods.RegisterMethods();
What's wrong in the code? I really cannot understand the docs.
thanks a lot.