Stop Add to Cart button to automatically leave the Product page

Topic summary

A user encountered an issue where clicking “Add to Cart” automatically redirected from the product page to the cart page in their modified Shopify Minimal theme. This behavior didn’t occur in other themes and wasn’t controllable through theme settings.

Solution Found:
The user resolved the issue by adding a single line of code to their product form’s add-to-cart button:

<input type="hidden" name="return_to" value="back" />

This hidden input field prevents the automatic redirect, keeping customers on the product page after adding items to cart. The fix was implemented directly in the theme’s Liquid code within the product form template.

Status: Resolved - the user shared the working solution for others experiencing the same issue.

Summarized with AI on November 13. AI used: claude-sonnet-4-5-20250929.

Hi all,

I see it was asked by a few people before but doesn’t work with my theme.

I use a modified Minimal theme.

When I add to cart a product, Shopify automatically leaves the product page and opens a cart page. I would like to turn off this feature. I do not have this option in my settings, looks like it’s something in the code.

It doesn’t happen when I preview with other themes.

Are there any ideas how I can change this?

Thanks a lot.

P.S. Not sure if it helps, this is the piece of code for the add to cart button in my product page:

{% form ‘product’, product, class: productform_class %}

{{ 'products.product.add_to_cart' | t }} {% if section.settings.enable_payment_button %} {{ form | payment_button }} {% endif %}

Hi all, just want to leave it for the record.

I added the following line to the button code and it worked:

Final add to cart code looks like this now:

{% form ‘product’, product, class: productform_class %}

{{ 'products.product.add_to_cart' | t }} {% if section.settings.enable_payment_button %} {{ form | payment_button }}

{% endif %}