I added this to my functions.php file :
add_filter (\'woocommerce_add_to_cart_redirect\', \'woo_redirect_to_checkout\');
function woo_redirect_to_checkout()
I wrote a little plugin for this, sharing it here. The plugin adds a small checkbox to the product metabox, so you can specify which products should trigger the automatic skip to checkout. Basically using the same woocommerce_add_to_cart_redirect
filter as in the other answers, but providing the admin backend option to determine which products trigger the redirection.
';
// Suggested Price
echo woocommerce_wp_checkbox( array(
'id' => '_redirect_to_checkout',
'label' => __( 'Redirect to checkout', 'kia-redirect-to-checkout' ) ,
'description' => __( 'When this item is added to the cart, re-direct the customer to checkout immediately.', 'kia-redirect-to-checkout' )
)
);
echo '
Updating WooCommerce 3.0+
';
// Suggested Price
echo woocommerce_wp_checkbox( array(
'id' => '_redirect_to_checkout',
'label' => __( 'Redirect to checkout', 'kia-redirect-to-checkout' ) ,
'description' => __( 'When this item is added to the cart, re-direct the customer to checkout immediately.', 'kia-redirect-to-checkout' )
)
);
echo '
https://gist.github.com/helgatheviking/f76b97d7d19813538e32b8f5f2dae6ec