Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Getting total number of units in shopping cart as opposed to items View modes: 
User avatar
Member
Member
iweber - 5/28/2013 3:08:27 PM
   
Getting total number of units in shopping cart as opposed to items
How can I get the total number of units in the shopping card altogether, rather than just the amount of items? I'm having real trouble on this and tried multiple methods, including making my own code behind.
Example:
int totalUnits = 0;

foreach (ShoppingCartItemInfo item in sc.CartItems)
{
totalUnits += item.CartItemUnits;
}
this.TotalPriceTitleText = totalUnits.ToString();
lblTotalPriceTitle.Text = this.TotalPriceTitleText.TrimEnd() + totalUnits.ToString();

Can anyone that knows how to do this fill me in on exactly what needs to be done?

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 5/29/2013 5:26:34 AM
   
RE:Getting total number of units in shopping cart as opposed to items
Hello,

You can simply use the Available properties of Shopping Cart, e.g:
int total_units = ECommerceContext.CurrentShoppingCart.TotalUnits;

Best regards,
Martin Danko