Looking for old forum posts and information? View the old forum archive here ยป
Welcome to Vortx Community Forum, where you can ask questions and receive answers from the staff at Vortx and other members of the community.

If you had a user account on our previous forums website, you will need to register a new account here.

A static copy of our previous forums website is available online for reference. Click here to access the forum archive.

Learn more about...

AspDotNetStorefront
DotFeed

Rendering ShoppingCart outside of ASP.net page flow

I have cloned the shoppingcart to allow for ajax paging (our carts can have over 100 line items). When I DataBind, only the lineitems needed for the page are selected and the associate item control is created. When I render the control (see below) and try to extract the html, I get only the header line.

The paging logic works perfectly when I display the first page,using the normal page rendering in AspDotNetStorefront with Asp.net.

Any suggestions?

Thanks


            var stringWriter = new StringWriter();
            var htmlwriter = new Html32TextWriter(stringWriter);
            control.DataBind();
            control.KboRenderControl(htmlwriter);
            return stringWriter.ToString();

        public void KboRenderControl(HtmlTextWriter writer)
        {
            EnsureChildControls();
            base.RenderControl(writer);
        }

In createChildControls I added 1 line to filter out unwanted cartitems ( which works for non-paging and selects only the items for that page).


                foreach (CartItem cItem in sortedCartItemForMinicart)
                {
                    if (KboDisplayCartItem()) // This limits displayed items to currentt page
                    {
                        cart = cItem.ThisShoppingCart; ....

Here'ss the paging selection logic:

        protected bool KboDisplayCartItem()
        {
            var displayCartItem = true;

            if (_kboPageSize > 0)
            {
                if (_kboCartItemIndex < _kboFirstCartItem ||
                    _kboCartItemIndex >= _kboFirstCartItem + _kboPageSize)
                {
                    displayCartItem = false;
                }
                _kboCartItemIndex++;
            }

            return displayCartItem;
        }

 

closed with the note: Programmer stupidity
asked Aug 29, 2015 in MultiStore by AbbottF (370 points)
closed Aug 31, 2015 by AbbottF

1 Answer

0 votes
I'm going to have to close this myself. There are a counter that was always set to 0 which forced the logic to skip displaying any line items.
answered Aug 31, 2015 by AbbottF (370 points)
...