How to extend the Shopping Cart Content Tables in Kentico
By Using the New Customization Model of the Kentico CMS, you can modify each available provider very easily. For example, In the process of extending the shopping cart content tables you can include a custom field which you have defined in the Site Manager > Development > edit COM_SKU table, only the thing you need to do is Override the CreateContentTableInternal and CreateContentRowInternal methods of the ShoppingCartInfoProvider class.
The first thing you need to do is Call Their Base Versions and then Modify the DataTable(in CreateContentTableInternal ) and DataRow (in CreateContentRowInternal)
Here is the Clear Demonstration:
*******************************************************************************
protected override DataTableCreateContentTableInternal()
{
DataTabledt = base.CreateContentTableInternal();
dt.Columns.Add(new DataColumn("<column name>", typeof(<type>)));
returndt;
}
protected override DataRowCreateContentRowInternal(ShoppingCartItemInfo item, DataTable table)
{
DataRow row = base.CreateContentRowInternal(item, table);
row["<column name>"] = item.SKUObj.GetValue("<SKU field name>");
return row;
}
*******************************************************************************
Then you can, for example, reference the custom field in the transformation, applied to the content table, by doing this:
{% ContentTable.ApplyTransform(String transformationName, String contentBeforeTransformationName, String contentAfterTransformationName) #% }
The first thing you need to do is Call Their Base Versions and then Modify the DataTable(in CreateContentTableInternal ) and DataRow (in CreateContentRowInternal)
Here is the Clear Demonstration:
*******************************************************************************
protected override DataTableCreateContentTableInternal()
{
DataTabledt = base.CreateContentTableInternal();
dt.Columns.Add(new DataColumn("<column name>", typeof(<type>)));
returndt;
}
protected override DataRowCreateContentRowInternal(ShoppingCartItemInfo item, DataTable table)
{
DataRow row = base.CreateContentRowInternal(item, table);
row["<column name>"] = item.SKUObj.GetValue("<SKU field name>");
return row;
}
*******************************************************************************
Then you can, for example, reference the custom field in the transformation, applied to the content table, by doing this:
{% ContentTable.ApplyTransform(String transformationName, String contentBeforeTransformationName, String contentAfterTransformationName) #% }