Redirect to Cart After Adding Product

This snippet redirects the user to the cart page immediately after adding a product, instead of staying on the product page.

PHP

function redirect_to_cart_after_add( $url ) {
    return wc_get_cart_url();
}
add_filter( 'woocommerce_add_to_cart_redirect', 'redirect_to_cart_after_add' );

Snippet Feedback

Did this snippet work for you? Do you have any questions about this snippet? Leave some feedback below.

Tags

Language

Did it work?

Save Snippet

Embed Snippet

To embed this snippet on your site, copy this html code and paste into your webpage. Learn more
By embedding snippets on your site, you are agreeing to our terms and conditions.

Embed Snippet

To embed this snippet on your site, copy this html code and paste into your webpage. Learn more
By embedding snippets on your site, you are agreeing to our terms and conditions.

Embed Snippet

To embed this snippet on your site, copy this html code and paste into your webpage. Learn more
By embedding snippets on your site, you are agreeing to our terms and conditions.