title: Prevent Redirect To Cart Page After Clicking Add To Cart - 3rd Party Shopify Theme
body: <p>When the add to cart button in hit, it takes you straight to the cart, which doesnt give shoppers an opportunity to shop around.</p>
  <p>How can I change it so that the page remains the same, so clients can continue shopping?</p>
  <p>I don’t have much experience in web development, but have attached the product-template.liquid, if that helps.</p>
  <p>Thank you all!</p>
  <pre><code>  {% endif %}
      {% if settings.upsell_popup_enable and upsell_enable %}
        $('.AddToCart').click(function(){
          var flag_addcart = true;
          $('.product_properties').each(function(){
            var val = $(this).find('input').val();
            var val_charlimit = $(this).find('input').data('charlimit');
            if(val == &quot;&quot;) {
              flag_addcart = false;
              $(this).find('input').addClass(&quot;ui-state-error&quot;);
            } else {
              $(this).find('input').removeClass(&quot;ui-state-error&quot;);
              $(this).find('.error-limit').hide();
              if(val_charlimit != undefined) {
                if(val.length &gt; val_charlimit){
                  flag_addcart = false;
                  $(this).find('input').addClass(&quot;ui-state-error&quot;);
                  $(this).find('.error-limit').html(&quot;Oops, we won't have space to print all that, try something shorter.&quot;).show();
                }
              }
            }
          });
          if(flag_addcart) {
            if($(window).width() &gt; 540){
              var width = &quot;500px&quot;;
            } else {
              var width = &quot;90%&quot;;  
            }
            $('#upsell-popup').find('.modal-content').css('width', width);
            $('#upsell-popup').addClass(&quot;in&quot;);
          }
          return false;
        });
        $('#upsell-popup .close-upsell').click(function(e){
          e.preventDefault();
          $('#upsell-popup').removeClass(&quot;in&quot;);
        });
        $('#upsell-popup .upsell-yes-btn').click(function(e){
          e.preventDefault();
          $('#upsell-popup').removeClass(&quot;in&quot;);
          $(&quot;#Quantity&quot;).val({{ settings.quantity_upsell }});
          var product_free_id = &quot;&quot;;
          {% for variant in all_products[settings.free_product].variants %}
            {% if variant == all_products[settings.free_product].selected_or_first_available_variant %}
              product_free_id = {{variant.id}};
            {% endif %}
          {% endfor %}
          if(product_free_id !== &quot;&quot;) {
            var data = 'id='+ product_free_id + '&amp;quantity=1';
            $.ajax({
              type: 'POST',
              url: '/cart/add.js',
              dataType: 'json',
              data: data,
              success: function(res){
                setTimeout(function(){
                  $(&quot;#AddToCartForm--{{ product.id }}&quot;).submit();
                }, 1000);
              }
            });
          } else {
            $(&quot;#AddToCartForm--{{ product.id }}&quot;).submit();
          }
          
        });
        $('#upsell-popup .upsell-no-btn').click(function(e){
          e.preventDefault();
          $('#upsell-popup').removeClass(&quot;in&quot;);
          $(&quot;#AddToCartForm--{{ product.id }}&quot;).submit();
        });
      {% endif %}
      {% for collection in product.collections limit: 1 %}
        timber.recordLastCollection({
          collection: &quot;{{ collection.handle }}&quot;
        });
      {% endfor %}
    });
  &lt;/script&gt;
  {% if settings.show_related_products %}
  &lt;hr class=&quot;releted--products-hr&quot; /&gt;
  </code></pre>