Search code examples
javascriptphpjquerywordpresswoocommerce

Refresh WooCommerce product page on added to cart


I am new to WordPress and I am using WooCommerce for a online store. I have found a small issue on one of the plugins that i needed for a specific product, and now I shall need to refresh the page automatically after adding the product on cart.

How can I easily do it without compromise the whole store? Is there anyway I can achieve this?

I did try to search for the origin php or js for add to cart event, but I couldn't find anything, and afterwards I tried to add a location.reload() to the add to cart class but it didn't solve my problem as well. This is everything i've tried so far.


Solution

  • Maybe this will work for you. It will refresh your page when the add to cart button is clicked. Add it to your functions.php

    add_action('woocommerce_add_to_cart', 'refresh_function');
    
    function refresh_function(){
    header("Refresh:0");
    }