cart
cart copied to clipboard
Mini-Cart button shows items contains after submit
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
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
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
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.
I‘ll check the behaviour after submitting the order.
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")
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.