cart icon indicating copy to clipboard operation
cart copied to clipboard

Mini-Cart button shows items contains after submit

Open X-Tender opened this issue 4 years ago • 5 comments

Bug Report

Current Behavior When the Order get submitted and the success state is shown, the mini cart button still show that he have items in it. after clicking on it or change page the mini-cart is shown as empty.

Expected behavior/output After the order was submitted the minicart should be shown empty

Environment

  • TYPO3 version(s): 9 latest
  • cart version: 6.9.2
  • Is your TYPO3 installation set up with Composer (Composer Mode): no
  • OS: linux

X-Tender avatar Feb 11 '21 15:02 X-Tender

I noticed this too after I completed an order.

I also noticed this behaviour when I add some items into the cart and go back via the return button

grafik

The previous page has then the cached umber of cart items.

For example, I have 0 items in my cart and go to a detail page of a product and add 5 items of this product into my cart. The cart shows now 5 items. Then I use the back-Button to go to the previous page. The cart shows now 0 items again.

When I reload the page it shows the correct number if items.

I guess it's a caching issue?

TYPO3 3 10.4.20 and cart 7.5, cart_products 3.1.1

medarob avatar Oct 19 '21 20:10 medarob

This is a browser caching issue. The JavaScript history.back() works like the back button of the browser. The page will shown from the lokal cache. Other shop software has the same problem. Even Amazon shows the wrong number on history back.

extcode avatar Oct 19 '21 20:10 extcode

I‘ll check the behaviour after submitting the order.

extcode avatar Oct 19 '21 20:10 extcode

I used this code, which I found in the #cart slack channel, for the mini cart

lib.cart_header = COA
lib.cart_header {
  10 = USER
  10 {
    userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
    extensionName = Cart
    pluginName = MiniCart
    vendorName = Extcode
    controller = Cart\CartPreview
    switchableControllerActions {
      Cart\CartPreview {
        1 = show
      }
    }
  }
}

and added it as a test to our header fluid code with

<f:cObject typoscriptObjectPath="lib.cart_header"/>

After submitting the order, the number of items will be kept.

If I change the lib.cart_header to COA_INT and 10 to USER_INT the mini cart shows 0 after submitting the order.

Not sure if there is any other way to add a mini cart to the header and if so, if that will help?

(Would be great to have this as an example in the documentation, maybe a page: "How to add a mini cart to the header")

medarob avatar Oct 19 '21 21:10 medarob

I tried in TYPO3 v12 the new content object EXTBASEPLUGIN

lib.miniCart = EXTBASEPLUGIN
lib.miniCart {
  extensionName = Cart
  pluginName = MiniCart
}

The problem is the same, after submitting the order the cart still shows the old status before submitting.

So I tried the (updated) solution of @medarob

lib.miniCart = COA_INT
lib.miniCart {
  10 = USER_INT
  10 {
    userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
    extensionName = Cart
    pluginName = MiniCart
    vendorName = Extcode
  }
}

Which works well for me.

@extcode I suggest adding this as snippet to the documentation and will create a PR when solving #454.

rintisch avatar Mar 23 '24 14:03 rintisch