Cart quantity in the shopping cart page

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
I want to create some messaging on the shopping cart page that needs to display the current quantity of items in the shopping cart.  I am sure that it is something simple like adding a using statement or calling the wrong thing.

I was hoping it would be something like @ShoppingCart.Quantity Or however the cart button gets its value.  Thanks for the help.
6 years ago
vbdoug wrote:
I want to create some messaging on the shopping cart page that needs to display the current quantity of items in the shopping cart.


Generally, There is a cart item loop at view page.

You could get item quantity over there.

Such,

@item.quantity


You have to sum those quantity by using linq query at view page
6 years ago
vbdoug wrote:
I want to create some messaging on the shopping cart page that needs to display the current quantity of items in the shopping cart.  I am sure that it is something simple like adding a using statement or calling the wrong thing.

I was hoping it would be something like @ShoppingCart.Quantity Or however the cart button gets its value.  Thanks for the help.


Try Like ==>


@{
    var cartQuantity = Model.Items.Sum(x => x.Quantity);
    
}

<h2>@cartQuantity</h2>



// Sohel
6 years ago
nopStation wrote:


Try Like ==>


@{
    var cartQuantity = Model.Items.Sum(x => x.Quantity);
    
}

<h2>@cartQuantity</h2>



// Sohel



That's perfect sohel.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.