• Resolved Laza Bogdan

    (@azgoku)


    Hello,I have a problem with a woocommerce website.

    The problem is , after I added a product to cart “?add-to-cart=72&quantity=1” this link remains in browser and if i refresh its adds the product again.
    Any ideea on how to fix it ?
    Thank You.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • I found this and it works for me:

    add_action( 'woocommerce_add_to_cart_redirect', 'prevent_duplicate_products_redirect' );
    function prevent_duplicate_products_redirect( $url = false ) {
      // if another plugin gets here first, let it keep the URL
      if( !empty( $url ) ) {
        return $url;
      }
      // redirect back to the original page, without the 'add-to-cart' parameter.
      // we add the 'get_bloginfo' part so it saves a redirect on https:// sites.
      return get_bloginfo( 'wpurl' ).add_query_arg( array(), remove_query_arg( 'add-to-cart' ) );
    } // end function
    

    We haven’t heard back from you in a while, so I’m going to mark this as resolved. If you have any further questions, you can start a new thread.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘“Add to cart” duplicates products on refresh’ is closed to new replies.