Posted By

catswhocode on 08/19/17


Tagged

wordpress woocommerce


Versions (?)

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


 / Published in: PHP
 

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

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.

  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 );

Report this snippet  

You need to login to post a comment.