Remove “?add-to-cart=product-id” from Add to Cart URL when on the Cart page

The solution would be to lose the ?add-to-cart=25part of the URL.
The simplest way to do that is with javascript History API:

history.pushState(null, "", location.href.split("?")[0]);

Docs: https://developer.mozilla.org/en-US/docs/Web/API/History_API

The DOM window object provides access to the browser’s history through the history object. It exposes useful methods and properties that let you move back and forth through the user’s history, as well as — starting with HTML5 — manipulate the contents of the history stack.

It was introduced in HTML5 so older browsers might not support it.

tech