I’m getting an odd behaviour when I remove an item from the mini cart while not on a single product page. I don’t have ajax add to cart enabled.
When it works normally:
If I am on a single product page and click add to cart, behaviour is normal. Add item to cart, receive a notice saying it has been added to cart, and then if I remove the item from mini cart it removes with ajax (and therefore does not show an alert, which is normal, as you can see the item vanishing from the mini cart).
When it behaves strangely:
Go to the home page
Click add to cart from the product loop
Notice that there is no alert yet, but we see the mini cart changes to show the item has been added
Now click on the mini cart and remove the item - the item looks to have removed, and it has.
Now I click on the product to view the single product page, and I see TWO alerts! From the previous actions. Something has gone haywire here.
Here is a loom recording where I do both scenarios. Doing it from the single product page works normally. But doing it from the home page produces strange results.
thank you for the video and the URL. I tested on your site, and I can see the issue. But, I can’t reproduce it locally on my install - using the same settings as you.
Can you reproduce this also with all the plugins disabled, and only Bricks + WooCommerce installed?
If yes, can you send temporary login credentials to your test/staging website and a link to this thread to help@bricksbuilder.io using the email address you used during the purchase, so we can take a look?
Thank you for the login details. I saw that you are using default WooCommerce notices, and with them, if you try to add/remove an item from the cart from /shop page, you will see that it will work as intended.
But because you do it from the home page, there is no WooCommerce notice there, so it shows them when you get to the page with notices.
If you check your website now, I’ve enabled “Bricks Notice” element in the settings, and I’ve added a Notice element to the home page and to the single product page. Now you can see that it’s working like it should.
Thanks for looking into that! I appreciate it, but it seems like a workaround to me. I really don’t want to use the Bricks Notice element because “You have to add the Notice element yourself wherever necessary as all native WooCommerce notices are removed when this setting is enabled.” That is so many templates. I want to keep things as simple as possible.
I actually don’t need a notice on the home page at all - what I need is for the Mini Cart to work normally on the home page the way it does when on a product page. You remove an item and it disappears with ajax and that’s that. No message displayed or needed. Go to the product page and you will see that for yourself. But then on the home page it seems to force a page load instead and now we need a notice.
How do we get the mini cart to work consistently throughout the site? Why does it work differently on other pages in my scenario? That is what I would say the issue is here
then, another way, is to add {do_action:woocommerce_before_shop_loop} somewhere in the homepage - probably above your products loop (WooCommerce Template Hooks – Bricks Academy). That way, it will work exactly the same as Storefront theme for example.
If you don’t want to show them, maybe you can just hide it with CSS. That way, the notice will “show” on home page and not on single product page.
But, if you don’t add that action, you will somehow need to clear the notices when you open the single product page or maybe even on cart change. You can clear it using wc_clear_notices();, and just call it in the desired hook.
Thanks Matej. Good to know. But if we put this notices thing aside, why doesn’t the Mini Cart work the same (when removing a product) on the home page as it does on a single product? If it did I’d have no problem here. No notices would be needed.
Off canvas Mini Cart removes via ajax on the Single Product page.
If doing the same from the home page on my staging link I provided, it does not remove via ajax and it forces a page load, therefore trying to show a notice.
If you look closely you can see it behaves differently in those instances. How do we get the mini cart to behave the same everywhere?
Hi @Matej - thanks for the reply. This solves that. So in order for the Mini Cart removal of items to work consistently via Ajax this has to be on. That’s unfortunate but I can live with this! I will keep it on always.
The other issue here is when using plugin “Advanced Product Fields Extended” by StudioWombat. I have activated it and set an option on one of the products on the home page.
If I have WooCommerece setting “Enable AJAX add to cart buttons on archives” things work just fine. I see “Select Options” under the product with options and click on it and it takes me through to the product. Great.
The problem is if I then go and turn on Bricks settings “Enable AJAX add to cart” - then clicking on that “Select options” product produces broken results. Instead of taking the user through to that product, it tries to add it via ajax and fails and then takes the user to that product page and shows an error.
It is a popular plugin by a good developer and he says it has been tested with Bricks. So how do we figure out what the cause of this broken behaviour is and how to fix it?
I can see the issue. As we don’t have special integration with this plugin, I think it’s best to contact the developer of the plugin, and explain the issue - especially if he said that it should be compatible.
Thanks @Matej - the Studio Wombat developer came back with feedback on why it’s an issue within Bricks and how it implements it’s own add to cart functionality. I forwarded the detailed info to Bricks support and they have emailed back offering a temporary fix and saying that this issue is now in the bug tracker. Just writing this in case anyone experiences this same issue.
I appreciate your efforts in getting to the bottom of this.