Apply Discount Code and Stay on Current Page

Is there a way to have a link (e.g., in the announcement bar) that applies a discount code and keeps the user on their current page, instead of redirecting to the homepage or a specific landing page?

Hey @Doug_Herman, you can do a fetch request, without following the redirect:

await fetch('/discount/MY_DISCOUNT_CODE')

<button onclick="fetch('/discount/MY_CODE').then(r => alert(r.ok ? 'Discount applied!' : 'Failed'))">
  Apply MY_CODE
</button>

How you implement this will depend specifically on your theme, approach etc!

Yes, you can apply a discount code via a link and keep the user on their current page using JavaScript.