PHP Snippet 1:
function firefog_custom_add_to_cart_redirect( $url ) {
$url = WC()->cart->get_cart_url();
return $url;
}
add_filter( 'woocommerce_cart_redirect_after_error', 'firefog_custom_add_to_cart_redirect' );
PHP Snippet 2:
function firefog_custom_add_to_cart_redirect( $url ) {
$url = WC()->cart->get_checkout_url();
return $url;
}
add_filter( 'woocommerce_add_to_cart_redirect', 'firefog_custom_add_to_cart_redirect' );
PHP Snippet 3:
<?php
$url = $_SERVER['REQUEST_URI'];
//change "ID" to your product id number (example:/shop/?add-to-cart=22 )
if($url==="/shop/?add-to-cart=ID"){
//change "/checkout" if your checkout page has a different url.
header("Location: /checkout");
die();
} else {
//your normal 404 page code here...
} ?>