• Resolved psodfj

    (@psodfj)


    Hi,
    I am building a custom shop page where I query individual products and call “woocommerce_template_single_add_to_cart” for each. The products are perfectly rendered but the problem is that clicking the “Add to cart” on a given product always redirects to that product in order to show the WooCommerce notice – either “The product has been added to your cart” or “You can’t add this product to your cart” (because of quantity restrictions).

    What I want is to show these WooCommerce messages on the custom shop page without redirecting to the product page. Should I change something in the “woocommerce_template_single_add_to_cart” template? Could the messages be shown in a pop-up, for instance?

    Many thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter psodfj

    (@psodfj)

    Alternatively, I can force “add to cart” to lead to the cart itself and this works fine for success messages, but error messages still redirect to the product page. Can I force all message to be shown in the cart then?

    Mirko P.

    (@rainfallnixfig)

    Hi @psodfj,

    Thanks for reaching out!

    I was testing this on a default install of WordPress, WooCommerce, and the Storefront theme and have seen that once you add the product to the cart from the shop page, it doesn’t redirect to the single product page, but it displays a “View cart” button on the shop page itself.

    Or the message appears on the top of the shop page if you disable AJAX add to cart buttons on archives.

    If you do not see the same, you might have come across a conflict or need to review how you’re building your custom shop page. You can find a more detailed explanation of how to do a conflict test here: https://docs.woocommerce.com/document/how-to-test-for-conflicts/.

    Cheers.

    We haven’t heard back from you in a while, so I’m marking this thread closed – we’ll be here if and/or when you are ready to continue.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show WooCommerce notices on any page without redirecting to the specific product’ is closed to new replies.