WordPress/WooCommerce - Redirect add to cart button to the checkout page


/ Published in: PHP

Automatically redirect users to the checkout page once a product has been added to the cart. This code should go to your functions.php file.


Copy this code and paste it in your HTML
  1. function add_to_cart_checkout_redirect() {
  2. wp_safe_redirect( get_permalink( get_option( 'woocommerce_checkout_page_id' ) ) );
  3. die();
  4. }
  5.  
  6. add_action( 'woocommerce_add_to_cart', 'add_to_cart_checkout_redirect', 16 );

URL: https://www.catswhocode.com/blog/super-useful-woocommerce-code-snippets

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.