[SOLVED] How can I skip the cart and go straight to checkout?

Tourist
5 0 4

Hi,

I need my  customers to go straight from clicking "Buy it now" to the checkout process. I am using the Debut theme.

Thanks,

James

0 Likes
Shopify Staff
Shopify Staff
540 0 67

Hey, James!

 

Savannah here from the Shopify Guru Team. :) 

 

It is technically possible to have the "add to cart" button go straight to the checkout, but we wouldn't really recommend it. It increases the number of abandoned checkouts, refunds and confusion because customers cannot review or update their purchases.

 

If you're still interested in making that change, one of the Experts lurking around this forum will likely be able to advise you on how to do that. 

 

Let me know if there's anything I can clarify! 

Savannah | Shopify Guru

0 Likes
Tourist
5 0 4

Savannah,

I understand the potential issues for customers, I do have a review after the checkout process. I still need to be able my add to cart button to go straight to check, so if anyone can help that'd be awesome.

Thanks,

James

0 Likes
Tourist
5 0 4

Hello Shopify,

I solved this issue on the Debut theme, but it may work for others.

In product-template.liquid find the following code:

<span id="AddToCartText-{{ section.id }}">

Make a backup of your file and right underneath it enter this code:

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

Customers will still be able to get back to cart from the breadcrumbs on the Checkout page and icon on your website, but it's a start.

Hope this helps,

James

2 Likes
New Member
2 0 0

The function code only for products where it has no variant once the prosuit contains variant ca no longer works on a variant of color or size the code no longer works

0 Likes
New Member
2 0 0
Shopify Partner
1 0 1

@Savannah ...so how do we technically have the "add to cart" button go straight to the checkout? No "Shopify Experts" has replied yet, its been 5 months!

1 Like
New Member
1 0 3

Try this:

<form action="/cart/add" method="post" class="variants" id="product-actions-{{ product.id }}" enctype="multipart/form-data">
<input type="hidden" name="variantId" value="{{ product.variants[0].id }}" />
<button class="button btn-cart btn_theme" title="Buy" onClick="instantBuy()"><span>Buy</span></button>
</form>

And the script below:
 

 function instantBuy(){
     var $ = jQuery;
     var formParams = $('form.cart').serialize();
     $.ajax({
      url: "/cart/add",
      type: "post",
      data: formParams,
      success: function(){
       window.location.href = "/checkout";
      },
      error: function(){
      }
     })
    }

    function addToCart(){
     $('form.cart').submit();
    }

 

3 Likes
New Member
9 0 0

Hi,

I applied this code from here https://help.shopify.com/themes/customization/products/add-to-cart/stay-on-product-page-when-items-a...

I am working on a app functionality and want to give this feature of redirecting directly to checkout skipping the cart page on add to cart. I have applied ajax for this which will redirect to checkout when success but this doesn't work for the themes which alredy have a ajax function running for add to cart. 

Is there a way to overwrite the predefined ajax without tempering with it. Or is there any other solution for this.

Thanks

aadrashmehta
0 Likes
New Member
1 0 0

Hey dude where do I add this code?

0 Likes