ASPX templates
Version 4.x > ASPX templates > Including a product image in the shopping cart View modes: 
User avatar
Member
Member
mrogers-brainloaf - 11/12/2009 11:24:44 AM
   
Including a product image in the shopping cart
Has anyone gotten a product image to display in a shopping cart?

I tried <%# EcommerceFunctions.GetProductImage(Eval("SKUImagePath"), 590, Eval("SKUName"))%>
<%# GetSKUName(Eval("SKUID"), Eval("SKUName"), Eval("CartItemParentGuid"))%>
<%# DisplaySKUErrorMessage( Eval("ErrorMessage"))%>

But SKUImage path isn't a part of the ShoppingCartContents data collection.

User avatar
Kentico Developer
Kentico Developer
kentico_ondrejv - 11/13/2009 9:14:13 AM
   
RE:Including a product image in the shopping cart
Hello,

Yes, you're right, you will need to perform following steps to achieve it:

1. Please create new metod in ~\CMSModules\Ecommerce\Controls\ShoppingCart\ShoppingCartContent.ascx.cs control's code-behind like this:

protected static string DisplaySKUImage(object skuId)
{
int currentSKUID = ValidationHelper.GetInteger(skuId, 0);
if (currentSKUID > 0)
{
SKUInfo sku = SKUInfoProvider.GetSKUInfo(currentSKUID);
if (sku != null)
{
return EcommerceFunctions.GetProductImage(sku.SKUImagePath, 40, sku.SKUName);
}
}
return null;
}


2. Now you are able to call this method in the control itself:

<%# DisplaySKUImage(Eval("SKUID"))%>


This will show product image with the shopping cart item list. Please note you could make that method even better by adding maxsidesize as a parameter, but it's up to you ;-)

Best regards
Ondrej Vasil