Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Stop Add to Cart button to automatically leave the Product page

Solved

Stop Add to Cart button to automatically leave the Product page

realina
Tourist
6 1 0

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 %}

<button type="submit" name="add" id="AddToCart" class="btn {{ btn_class }}{% if section.settings.enable_payment_button and product.selling_plan_groups == empty %} btn--secondary{% endif %} cart-button">
<span id="AddToCartText">{{ 'products.product.add_to_cart' | t }}</span>
</button>
{% if section.settings.enable_payment_button %}
{{ form | payment_button }}
{% endif %}

Accepted Solution (1)

realina
Tourist
6 1 0

This is an accepted solution.

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

 

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

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

 

Final add to cart code looks like this now:

 

{% form 'product', product, class: productform_class %}

<button type="submit" name="add" id="AddToCart" class="btn {{ btn_class }}{% if section.settings.enable_payment_button and product.selling_plan_groups == empty %} btn--secondary{% endif %} cart-button">
<span id="AddToCartText">{{ 'products.product.add_to_cart' | t }}</span>
<input type="hidden" name="return_to" value="back" />
</button>
{% if section.settings.enable_payment_button %}
{{ form | payment_button }}

{% endif %}

View solution in original post

Reply 1 (1)

realina
Tourist
6 1 0

This is an accepted solution.

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

 

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

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

 

Final add to cart code looks like this now:

 

{% form 'product', product, class: productform_class %}

<button type="submit" name="add" id="AddToCart" class="btn {{ btn_class }}{% if section.settings.enable_payment_button and product.selling_plan_groups == empty %} btn--secondary{% endif %} cart-button">
<span id="AddToCartText">{{ 'products.product.add_to_cart' | t }}</span>
<input type="hidden" name="return_to" value="back" />
</button>
{% if section.settings.enable_payment_button %}
{{ form | payment_button }}

{% endif %}