Hello Shopify developers, I am facing a problem.
I am using the Horizon theme in Shopify. Inside it, I have created an “Add to Cart” button that adds the product to the cart.
When I click on that button, the product does get added to the cart, but it redirects me to the cart page. I do not want this behavior.
I am using a cart drawer, so I want the cart drawer to open instead of redirecting to the cart page.
What should I do? I am sharing the code below.
<input type="hidden" name="id" value="{{ product.selected_or_first_available_variant.id }}">
<button type="submit" class="cursor-pointer">
<svg width="43" height="43" viewBox="0 0 43 43" fill="none" xmlns=" http://www.w3.org/2000/svg ">
<rect width="43" height="43" rx="21.5" fill="#F37421"/>
<path d="M32 19.25V24.75H23.75V33H18.25V24.75H10V19.25H18.25V11H23.75V19.25H32Z" fill="white"/>
</svg>
</button>
</form>