Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > How to Evaluate Shopping Cart Content? View modes: 
User avatar
Member
Member
iweber - 8/13/2013 2:10:07 PM
   
How to Evaluate Shopping Cart Content?
I need to work on customizing (overriding) the EvaluateContentInternal method for the Kentico 6.0 ShoppingCartInfoProvider. This is so that I can get the final shopping cart pages to display in a different way (ultimately, I want to use different variables in the end because the default ones are not suitable for the calculations which we have done for calculating price, taxes, etc on this site). I need to change the way the subtotal and unit price are being calculated on the shopping cart page.

I'm encountering an error now because I can't override the method using conventional methods. What I want to do is not change the original ShoppingCart's content table, but simply add additional columns to it, CustomPrice, CustomSubTotal, etc. I was wondering if someone can point me in the right direction on how to do this, or if this is actually possible.

I will add more detail shortly.

User avatar
Member
Member
iweber - 8/13/2013 2:55:58 PM
   
RE:How to Evaluate Shopping Cart Content?
Okay I am trying to run a loop through the DataTable, the ShoppingCart's current content:
The first function is how I add a new column to the table. The 2nd is how I am trying to loop over all the items, and then simply put in 0 in the new column which I added (as a sort of primary test to see if it's actually working).
protected override DataTable CreateContentTableInternal()
{
DataTable dt = base.CreateContentTableInternal();
dt.Columns.Add(new DataColumn("CustomItemPrice", typeof(double)));
return dt;
}

protected override DataTable EvaluateContentInternal(ShoppingCartInfo cart)
{
cart = ECommerceContext.CurrentShoppingCart;
foreach (DataRow row in cart.ContentTable.Rows)
{
row["CustomItemPrice"] = 0;
}

return cart.ContentTable;
}

Unfortunately this results in either a StackOverflow exception, or I simply cannot override the method for some reason. If I change the method from being void to having a return type, I simply cannot override the method at all.

User avatar
Member
Member
kentico_johnathan - 8/20/2013 2:22:27 PM
   
RE:How to Evaluate Shopping Cart Content?
Where are you trying to override the method at? Typically this would be done in a custom ShoppingCartInfoProvider, but I'm unclear as to whether you are doing this or trying to override the default ShoppingCartInfoProvider methods.

EvaluateContentInternal uses both CreateContentTableInternal and CreateContentRowInternal, so you would also need to override these methods in your custom ShoppingCartInfoProvider provider. You need to call their base versions and then modify the returned DataTable (in the CreateContentTableInternal) and DataRow (in the CreateContentRowInternal).