Add to cart alert

The add to cart alert is loading on the checkout page instead of the page that the add to cart is occurring. Can I force the alert to occur on the page it occurs on ?

Hello @wicara,

Thanks for writing in!

When you click add to cart button, does it redirects to the cart page? If that is the case, then you must disable the redirect instead. Please go to WooCommerce > Settings > Products > General and unchecked the Add to cart behaviour.

Hope this helps.

no neither of those. it refreshes the page the product is on and then add to the cart

Hi @wicara,

Then we need to make sure we understand the case correctly. Would you please kindly get back to us with the URL/User?pass of the website you are talking about via Secure Note and give us the steps we should take to see the alert in question?

Meanwhile, I wonder if you can go to WordPress Dashboard > X/Pro > Theme Options > Woocommerce and enable the Ajax alert?

Thank you.

looking through the options there is no enable ajax alert there is ajax add to cart but no alert option

Hello @wicara,

Yes what is available only is ajax add to cart. When you add product, there will be a message on top. Something like this: https://screencast-o-matic.com/watch/cqio1nOYtU. If you are looking for a function more than that, unfortunately, it is not available by default on woocommerce. You might want to check other plugins with that function. A general search point me to this plugin. It is not a supported plugin though it might achieve the feature you need. Hope this helps.

This is more what I was after trying to get this to display on the page it is added eg home page archive page ect

Hi @wicara,

Thank you for the clarification.
By default on woocommerce, it is only added on single product page. I have checked templates and it will be possible with a customization that is outside the scope of our support. For single product page, it was added using the following lines:

add_action( 'woocommerce_before_single_product', 'woocommerce_output_all_notices', 10 );

That line of code is added on this file below around line 298 under Notices
\wp-content\plugins\woocommerce\includes\wc-template-hooks.php

It will not work on shop page or archive page because there are difference in button structure. On single product page, add to cart buttin is a submit button that reloads that’s why that function works. On shop/archive page, add to cart button is just a link. The page doesn’t reload when you add the product. Thank you.

please see my site and see how it does reload the same page

would this still work for single product pages ? https://michaelbourne.ca/enabling-ajax-add-to-cart-on-single-product-views-with-x-overlay/

Hi @wicara,

You might try to add this line on your child theme’s functions.php file:

add_action( 'woocommerce_before_main_content', 'woocommerce_output_all_notices', 10 );

Try that and see if it will work tho show notice/alert on your archive or shop page.

Yes, the code should still work on single product pages.

Tried that and it did not work

Hey @wicara,

In this case, you need to consult with a third-party developer as this would require troubleshooting a WooCommerce feature and not a feature of our theme.

If hiring a developer is not feasible, you could try Added to Cart Popups like this plugin: https://wordpress.org/plugins/added-to-cart-popup-woocommerce/

Thank you for understanding.

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