# Go Straight to Checkout After Adding to Cart

> Skips the cart page and sends customers directly to checkout after they add a product, for single-product or quick-purchase stores.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, checkout, redirect, add-to-cart
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-redirect-to-checkout/

## Code

```php
add_filter( 'woocommerce_add_to_cart_redirect', function () {
    return wc_get_checkout_url();
} );
```

## Notes

Turn off "Enable AJAX add to cart buttons on archives" in WooCommerce > Settings > Products so shop buttons redirect too.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Go Straight to Checkout After Adding to Cart" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
