Shop Notices Not Displaying

Hi,

For some reason the Shop Notices are not displaying on Woocommerce Single Layout pages. For example, if I add a product to the Basket/Cart, I would expect a shop notice to appear, stating that item X has been added to the basket.

Shop Notices work on the WC Archive Layout, but not on the WC Single Layout.

Thanks,
Christopher

Howdy @cdnwhite, thanks for writing in! WooCommerce is a little convoluted in how it handles certain bits of functionality, so hopefully I can help to illustrate a few different ways you might want to set things up depending on what you’re trying to achieve.

The first thing to be aware of is the control for allowing AJAX add to cart buttons at WordPress AdminWooCommerceSettingsProductsGeneralAdd to cart behaviourEnable AJAX add to cart buttons on archives:

While this setting says “on archives,” it’s really just a collection of special HTML attributes that are added to certain links on the archives with the default WooCommerce templates that trigger this AJAX add to cart action. If you were to add our “Add to Cart Button” Element onto a page in the Layout Builder in Pro, you will find under the Customize tab this is simply a Button Element that we’ve already applied all of those attributes to for you to place anywhere in your design:

So if that setting in the admin is checked at all and you’re using that Element to add a product to a cart, it will always trigger an AJAX add to cart action. When the AJAX action is triggered, our in-built theme feedback shows up to show an item being added to your cart, which bypasses any Shop Notices from being output. Now, if you were to disable that admin setting, you will find that clicking that button still works, but now your notices will trigger:

Additionally, you could keep the AJAX setting checked if desired, but swap out the “Add to Cart Button” with the “Add to Cart Form” Element, which is a native WooCommerce Element that will always add items to your cart via a page session / refresh:

As of right now, the one downside to using this Element is that it cannot be styled natively in the Builder as it will take on the global button styles from your Theme Options and the global form styling from the Stack you have selected in Theme Options, but you will get the quantity form and the button will always trigger notices.

So there’s a few different things to be aware of when setting up your Product pages and how certain Elements interact with your shop depending on that setting in the WordPress admin. Hopefully this all helps to point you in the right direction with things…cheers!

Howdy Kory,

Thank you so much for such a great insight into the workings of Woocommerce. the guide is a massive help!

Unchecking the Ajax checkbox did the trick for me instantly. I also have tried using the Add to Cart Form element to see the difference between it and the button. I can see how each will be useful in different scenarios.

As this website will be using just digital downloads and affiliate links, the button combined with Ajax checkbox solution is just what I need.

Many thanks again and I am sure your detailed explanation will be useful to many others in the future!

Best wishes,
Christopher

Thanks very much, Christopher! Glad to hear it helped.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.