Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > ShoppingCart Web Part Display Options View modes: 
User avatar
Member
Member
jwilson-bostwicklaboratories - 3/23/2011 3:38:48 PM
   
ShoppingCart Web Part Display Options
My company would like to add the Product number to the shopping cart page. As of right now, the only columns in the shopping cart display table are: Remove, Product Name, Units, Unit Price, Tax, and Subtotal. We would then like to have that product number added to the notification e-mails that all purchases send out automatically.

I noticed that the emails use the macro ##productlist## to display the shopping cart information.

Can I edit that macro to include the Product Number? If so, where might I find the code to edit? If not, I would really appreciate any advice on where else I should be looking.

Thanks,
Jon

User avatar
Kentico Consulting
Kentico Consulting
kentico_mirekr - 3/29/2011 5:09:19 AM
   
RE:ShoppingCart Web Part Display Options
Hi,

If you would like to add custom field to ShoppingCartContent table you would need to overwrite EvaluateShoppingCartContent method in CustomShoppingCartInfoProvider class:

http://devnet.kentico.com/docs/ecommerceguide/customshoppingcartinfoprovider.htm

You can call default EvaluateShoppingCartContent method and then add your custom field to resulting ShoppingCartContent object. This object is standard .NET DataTable and it is used for example in first shopping cart step to populate GridView control that displays the items of shopping cart as well as when productlist macro is replaced with data from shopping cart.

As regards to productlist macro, you would need to override CMS.Ecommerce.OrderInfoProvider.GetProductList method that is used when creating product list and add custom fields to this method:

http://devnet.kentico.com/Forums.aspx?forumid=36&threadid=17443

You can also use custom macros for this purpose instead of calling default productlist macro.

Best regards,
Miro Remias.

User avatar
Member
Member
jwilson-bostwicklaboratories - 3/29/2011 8:59:49 AM
   
RE:ShoppingCart Web Part Display Options
Thank you very much. I will check all of this out and let you know how it works out.

Jon

User avatar
Member
Member
jwilson-bostwicklaboratories - 3/29/2011 11:42:39 AM
   
RE:ShoppingCart Web Part Display Options
So I am feeling like quite a dummy right now because I can't even find the files I need to adjust the settings for any of this.

I've been trying to mess around with the files in this folder:

\CMSModules\Ecommerce\Controls\ShoppingCart.

It seems that the ShoppingCart.aspx and ShoppingCartContent.aspx files are the one that populate the form; however every time I try to add the Product Number, the webpage will not display the code.

I really want to keep the ProductList macro in the same spot and just have it pull another value into it (the Product Number).

Any more help would be greatly appreciated...I am completely lost still.

Thanks,
Jon




User avatar
Member
Member
jwilson-bostwicklaboratories - 3/31/2011 1:31:52 PM
   
RE:ShoppingCart Web Part Display Options
Ok this is driving me crazy. I'm pretty sure that the files I want to change are ShoppingCartContent.ascx and ShoppingCartContent.ascx.cs. This is where the source code is generating the code for the cart table.

If anyone out there knows anything about what I need to change here to add a Product Number to the gridData table (or anywhere on the page for that matter), I would greatly appreciate it.

Thanks,
Jon

User avatar
Kentico Consulting
Kentico Consulting
kentico_mirekr - 4/11/2011 8:56:43 AM
   
RE:ShoppingCart Web Part Display Options
Hi,

ShoppingCartInfo object in ~\CMSModules\Ecommerce\Controls\ShoppingCart\ShoppingCartContent.ascx.cs file holds the data in ShoppingCartContentTable property, that is basically standard ASP.NET DataTable object that is assigned to GridView’s DataSource property in ReloadData method:

gridData.DataSource = ShoppingCartInfoObj.ShoppingCartContentTable;


ShoppingCartContentTable table contains following fields:

SKUID, SKUName, SKUUnits, SKUUnits, SKUPrice, UnitDiscount, Tax, SubTotal, SubTotalDefaultCurrency, ErrorMessage, CartItemID , CartItemGuid, CartItemParentGuid

If you would like to extend this table to use another field (SKUNumber), you need to include such field into this table in EvaluateShoppingCartContent method where this ShoppingCartContentTable is created.

So, as I mentioned previously, you need to use custom e-commerce providers for this purpose and overwrite CustomShoppingCartInfoProvider.EvaluateShoppingCartContent method:

http://devnet.kentico.com/docs/ecommerceguide/customshoppingcartinfoprovider.htm

You can call default Kentico CMS method so that the ShoppingCartContentTable is created and then you need to modify the ShoppingCartContentTable and include your custom field.

I hope this will help you.

Best regards,
Miro Remias.

User avatar
Certified Developer v7
Certified  Developer v7
magnus-lgo - 6/9/2011 4:52:01 PM
   
RE:ShoppingCart Web Part Display Options
Hi Jon,
First of, i need to know if you understand the concept of using a custom provider as descriped in the documentation?

If not, then just follow the steps outlined here. When you get to the point where it says
4. Delete the CMS.CustomECommerceProvider.dll file from the /bin directory of the CMS project.
dont be frustrated if you dont have that DLL in your solution by this time.

Once you done this (and it sounds a lot more hairy than it is!) you should alter the code in the file in the new project that you created. The file is named "CustomShoppingCartInfoProvider.cs"

In line 23 you find the method called:
public void EvaluateShoppingCartContent(object shoppingCart)

This method should be recreated to look something like this:
       public void EvaluateShoppingCartContent(object shoppingCart)
{
ShoppingCartInfoProvider.EvaluateShoppingCartContent((CMS.Ecommerce.ShoppingCartInfo)shoppingCart);

CMS.Ecommerce.ShoppingCartInfo si = (CMS.Ecommerce.ShoppingCartInfo)shoppingCart;
si.ShoppingCartContentTable.Columns.Add("skuNumber", typeof(string));

foreach (DataRow skuRow in si.ShoppingCartContentTable.Rows)
{
CMS.Ecommerce.SKUInfo sInfo = SKUInfoProvider.GetSKUInfo((int)skuRow["skuID"]);
skuRow["skuNumber"] = sInfo.SKUNumber.ToString();
}
}


If you want the same to go for the shoppingCartPreview.ascx file (also on this usercontrol there is a grid showing the content of the cart) then you need to add the same logik to the overloaded method with the same name just below the first one. That is:
        public void EvaluateShoppingCartContent(object shoppingCart, bool evaluateForInvoice)
{
ShoppingCartInfoProvider.EvaluateShoppingCartContent((CMS.Ecommerce.ShoppingCartInfo)shoppingCart, evaluateForInvoice);

CMS.Ecommerce.ShoppingCartInfo si = (CMS.Ecommerce.ShoppingCartInfo)shoppingCart;
si.ShoppingCartContentTable.Columns.Add("skuNumber", typeof(string));

foreach (DataRow skuRow in si.ShoppingCartContentTable.Rows)
{
CMS.Ecommerce.SKUInfo sInfo = SKUInfoProvider.GetSKUInfo((int)skuRow["skuID"]);
skuRow["skuNumber"] = sInfo.SKUNumber.ToString();
}

}


If you want to add more fields from the SKU table, or customfields for the SKU table make sure to specify them in the dataTable definition first:
si.ShoppingCartContentTable.Columns.Add("myOwnSpecialSKUfield", typeof(string));


And then add them in the foreach loop where you will add values to them like:
skuRow["myOwnSpecialSKUfield"] = sInfo.getValue("myOwnSpecialSKUfield").ToString();


for the confirmation email i would recommend that you create a custom macro for that.

Hope this helps out a little...

User avatar
Certified Developer v7
Certified  Developer v7
magnus-lgo - 6/9/2011 5:16:56 PM
   
RE:ShoppingCart Web Part Display Options
In addition you should check to see if the coloumn exists on the datatable before creating it... So in the code from my previous post you should change
si.ShoppingCartContentTable.Columns.Add("skuNumber", typeof(string));

to:
if (!si.ShoppingCartContentTable.Columns.Contains("skuNumber"))
si.ShoppingCartContentTable.Columns.Add("skuNumber", typeof(string));


If you dont, and you put the code for both method definitions it will throw an error saying that the coloumn already exists on the table... at least on the shoppingCartPreview.ascx usercontrol...

Happy hunting
Magnus