The following blog post describes the steps you need to take in order to display information about the custom product fields in the shopping cart.
By design, the Shopping cart widget template displays information about the purchased products including the product's title, the product's price, the quantity, subtotal price as shown in the screenshot below:
It is possible that you may want to add some additional columns to the grid to display the values of custom product fields. If you try to achieve this by just modifying the Shopping cart template and add an additional column for the custom field for example by using the following markup for the RadGrid column:
Sitefinity will throw the following exception:
It is expected that Sitefinity throws this exception since we bind the RadGrid to the CartDetail object which by design does not contain the custom product fields.
In order to add a custom field to the shopping cart grid you need to create and map an external template for the shopping cart widget. Then in the code behind of your custom template you will be able to get the values of the custom field for the purchased products and bind these values to the custom column.
The first step will be to get the default template of the Shopping cart. In order to do this, please open the Shopping cart widget in edit mode and then click on the Edit template … button under the Shopping cart template label as shown in the screenshot.
Please copy the markup of the default template.
The next step will be to create a user control (an .ascx file) in your project and paste the markup of the default template you have just copied. After that you can add a new column in the RadGrid which will display the custom field values. For example you can place the new column between the ‘ProductDescription’ and 'Options' columns. Here is a sample markup of the column for the custom field which you can use as a sample:
Please note that you can change the value of the UniqueName attribute of the GridTemplateColumn tag and the ID of the Literal and set them as desired.
What is left is to subscribe to the RadGrid's ItemDataBound event in the code behind of the custom template. Then on item data bound you can get the product id from the CartDetail so that you can get the product by its id. After you get the product you will be able to get the value of the custom field by the field name and to add the custom field to the column. You can use the sample code below as an example:
ShoppingCartCustomTemplate : System.Web.UI.UserControl
sender, EventArgs e)
sender, GridItemEventArgs e)
GridDataItem item = (GridDataItem)e.Item;
CartDetail cartDetail = (CartDetail)item.DataItem;
Guid productId = cartDetail.ProductId;
CatalogManager catalogMgr = CatalogManager.GetManager();
Product product = catalogMgr.GetProduct(productId);
Literal lit = (Literal)item[
lit.Text = product.GetValue(
I have also prepared a short video for your convenience demonstrating the steps and the results after implementing this following the above sample. You can download the video from the following link.
I hope you will find the blog post helpful.
Sabrie Nedzhip is a Tech Support Engineer at Telerik. She joined the Sitefinity Support team in December 2013.
Subscribe to get all the news, info and tutorials you need to build better business apps and sites
You have the right to request deletion of your Personal Information at any time.
You can also ask us not to pass your Personal Information to third parties here: Do Not Sell My Info
Copyright © 2020 Progress Software Corporation and/or its subsidiaries or affiliates.All Rights Reserved.
Progress, Telerik, Ipswitch, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.