WooCommerce: Skip Product & Cart Pages

That’s a common issue some of you (WooCommerce users) face: how to click on one single button to add a product to the cart without even visiting the product page and skip the cart page to be directly redirected to the checkout page.

Let’s say you sell a ebook, and you lost potential sales during the Home Page > Product Page > Cart Page > Checkout Page funnel… Well this can be avoided by adding a link on the homepage and being redirected to the checkout directly with the product being added to the cart automatically.

To do it, simply add a link on your homepage (why not in the header?) and use a URL having this structure:

http://your-site.com/?add-to-cart=37

Where you replace 37 by the product ID.

Then add this snippet to the functions.php file within your theme folder, and tada ! The magic appears !

About the author

Remi Hey! My name is Rémi Corson, I'm a French WordPress Developer, I code stuff and I write from time to time ;-) Buy a coffee
Show your support

Related Posts

24 comments

  1. soralsokal:

    Hi Remi,

    on my quest I found your article on skipping the product page.

    I actually want to have an “add to cart” button, but also show the product options next to it. Any idea, how to accomplish this?

    Thanks,
    Robin

  2. roman:

    Hi Remi,

    This saved my life. Unfortunately, though, it causes Woocommerce to add the product twice to the cart. I tried the “sell this product individually” setting but then the link no longer works and redirects to the home page instead.

    Is there anyway to only have it add one product to the account?

    • burnbright:

      Hello, Remi. I am seeing something similar with the redirect. If users add a product to their cart, then navigate to a different page, and then try to re-add a subscription product to their cart, the user is redirected to the home page.

      Any thoughts on how to fix this?

      Thanks in advance for your help!

      DG

  3. dreadedhamish:

    Can I skip the cart and checkout completely?
    Use case: I have some virtual free products. I don’t want them to be external products because I want the metrics woocommerce supply.

    So my logic would be “If virtual without add-on” then “complete checkout”. All users are registered already.

    Do you think I can combine this method and the code you had for removing fields from the checkout for virtual products, and end up with a shop that auto-emails you the download when you click on BUY, but puts you through checkout if it’s a product with an add-on or non-virtual?

    Thanks,
    Hamish

  4. dragnfly:

    Hi Remi

    This code works great thanks.

    Is it possible to redirect from the product archive page as well?

  5. crazyyy:

    Hello there, Remi. I’ve done everything as you mentioned above, the link appears where it should be, but when i click on it, i am getting log out and redirected on my homepage. Any suggestions? Thanks in advance.

  6. labowc:

    hi,
    sorry if my question goes beyond the scope of this post..
    here my problem:
    i would like to bypass cart and checkout of my site and link the “add to cart” button to an url maked “ad hoc” with the variables of my variable products.
    is it possible? how? does exists plugins or extensions that do it? can you give-me some examples of code that do it?
    thanks for the attention.
    regards

  7. Vlietson:

    Hi Remi,

    Sounds perfect, did everything you said. But I will get the message: Your Cart is empty. So no product is automatically added to the cart. Could you help me to fix this? Thanks

  8. shishirumrao:

    Hi Remi,

    I got a similar problem as above. But this happens only for guests, i.e, when any guest adds the product to cart, it redirects to cart page saying “cart is empty”.

    But for registered users it works perfect.

    Any idea how to fix for guests ??

    Thanks
    -Shishir

  9. tlearyus:

    Remi I simply want to redirect the product links so that they go to a custom URL that I can set for each product. i.e. I don’t want to use the default Woocommerce shop.

    I have searched for hour trying work out how to do this but can’t seem to find a way that works.

    Any solution would be greatly appreciated.

  10. ewoah:

    It seems this functionality broke since I updated to the lastest version of woocommerce. The product does get added to the cart, but It doesn’t redirect me to the checkout page. Any idea for a solution?

    Thanks

  11. therawjuicery:

    Hi Remi,

    I want to skip the Product and Cart page (Custom Page -> Checkout) but what this post suggests to do does not work and only forwards the customer to the home page. I know this post is outdated. Is there a fix that is relevant today that you may have up your sleeve? Thank you very much for your time and have a great day.

  12. Mattbi:

    When I add the code to functions.php, my whole site gets a 500 error. :(

  13. msenoussi:

    Hi Remi thanks for the tip ! I’d like to know if you can just use that code for selected products ! I’ve a got a custom message product just before the checkout and I’d like it to lead the client directly to the checkout once he has set his message !

    Any idea ?

  14. mtdallaire:

    Hi,
    I was wondering if this code is still up-to-date from Woo 3.0 ?

    Also, while skipping, is it possible to add Meta Data that appears in the order, so I can use it when I revise the order?

    I only have one virtual product, but that product is virtual. It will be sent by email when payment is done. So I don’t need a cart or a product page. My product page is a custom page where you can build an image.

    I’m very happy to have discovered your blog, it’s very insightful. I sent you some coffee!! :-) Have a good one!

    Cheers!

  15. arch:

    Hey Remi

    This was super helpful, but what to do if I only want to skip the product page and redirect to the cart? I can’t find the answer to that anywhere.

    Thanks in advance.

Leave a Reply