NOP v2.80 - Shopping Cart Item Count

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
I discovered when working on the FlyoutShoppingCart.cshtml view that when items are added to the shopping cart and the quantities are greater than one, the flyout cart will display the message, "There are {{ITEM QTY TOTAL}} items in your cart." This should not report the total qty of items in ones cart. Rather it should report the # of items in ones cart. To do this, a simple change in the view would be like this:

OLD:
@Html.Raw(string.Format(T("ShoppingCart.Mini.SeveralItemsText").Text, string.Format("<a href=\"{0}\" class=\"items\">{1}</a>", Url.RouteUrl("ShoppingCart"), string.Format(T("ShoppingCart.Mini.SeveralItems").Text, Model.TotalProducts))))

NEW:
@Html.Raw(string.Format(T("ShoppingCart.Mini.SeveralItemsText").Text, string.Format("<a href=\"{0}\" class=\"items\">{1}</a>", Url.RouteUrl("ShoppingCart"), string.Format(T("ShoppingCart.Mini.SeveralItems").Text, Model.Items.Count))))

Thanks,

Greggory
Acoustic Ceiling Products
http://acpideas.com
Senior Web Developer
11 years ago
Everything works fine as designed. We display the total number (Qty) of ALL products in the cart. It works the same way as in the top "shopping cart (QTY)" link.

Furthermore, flyout shopping cart does not display ALL products in the cart. By default it displays only first 5 products.

If you don't like this behavior you can always change it.
11 years ago
Andre,

Thanks for your feedback. I feel this is a setting based on preference. Maybe this could be a setting in the store that would allow users to select between the number of items OR the number of item quantities? Also, since the cart only displays five items, maybe that should also be a setting in the admin section to allow users to decide on how many they would like to display. Just some suggestions.

With that being said, 2.80 is certainly better than the previous versions! The only thing lacking is the one page checkout. If I happen to work on a plugin or alter the views/controllers, I would be willing to send you the code for future releases. :)

Thanks,

Greggory
11 years ago
Andre,

Scratch the previous comment about the number of items in the flyout shopping cart. I see that you all did include that setting in the admin section. Sorry.

Greggory
11 years ago
Tealmad, I am modifying the site to work as a material ordering interface.  When you order electrcal conduit, you may order 1000', or if you order connectors, you might order 100 or a "box".  By modifying the flyoout to the number of items in your cart, this is a step in the right direction for me.
Thanks
11 years ago
DVClark, Good to hear the small modification works best for you.

Thanks,

Greggory
11 years ago
Tealmad,  That worked for the flyout shopping cart, but I have not been able to modify the header link to display the number of items instead of quantity.  Below is a line from HeaderLinks.cshtml:
@if (Model.ShoppingCartEnabled)
        {
            <li id="topcartlink"><a href="@Url.RouteUrl("ShoppingCart")" class="ico-cart">@T("ShoppingCart")</a>
                 <a href="@Url.RouteUrl("ShoppingCart")" class="cart-qty">(@Model.ShoppingCartItems)</a>
            </li>

Any ideas?  I keep getting errors if I try to put any .count function.
Sorry that Bug Reports is not really the proper forum for this topic, but since we are here might as well finish it.
Thanks
11 years ago
DVClark,

Be sure you change the code based on the bold text:

OLD:
@Html.Raw(string.Format(T("ShoppingCart.Mini.SeveralItemsText").Text, string.Format("<a href=\"{0}\" class=\"items\">{1}</a>", Url.RouteUrl("ShoppingCart"), string.Format(T("ShoppingCart.Mini.SeveralItems")Text, .Model.TotalProducts))))

NEW:
@Html.Raw(string.Format(T("ShoppingCart.Mini.SeveralItemsText").Text, string.Format("<a href=\"{0}\" class=\"items\">{1}</a>", Url.RouteUrl("ShoppingCart"), string.Format(T("ShoppingCart.Mini.SeveralItems").Text, Model.Items.Count))))

Notice that I am using  Model.Items.Count.

Try that and see if you get that to work.

Greggory
11 years ago
DVClark,

I also see that you a not referencing the correct model. That is why you are having problems. You would have to make sure the model has the ability to provide a count of items, if that makes sense. If it is a collection, you should be able to get a count of them.

Greggory
10 years ago
the code works ok, but I need to make the same change in header link and I can not do it. suggestions?
thanks
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.