Refresh wooCommerce product page on added to cart problem

Refresh your page when the add to cart button is clicked. Add it to your functions.php / plugin

One Way

  1. add_action('woocommerce_add_to_cart', 'refresh_function');
  2. function refresh_function(){
  3. header("Refresh:0");
  4. }

Another Way

  1. add_action('woocommerce_add_to_cart_redirect', 'refresh_function');
  2. function refresh_function($url = false) {
  3. // If another plugin beats us to the punch, let them have their way with the URL
  4. if(!empty($url)) { return $url; }
  5. // Redirect back to the original page, without the 'add-to-cart' parameter.
  6. // We add the `get_bloginfo` part so it saves a redirect on https:// sites.
  7. return get_bloginfo('wpurl').add_query_arg(array(), remove_query_arg('add-to-cart'));
  8. }

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>