wpgenie

Redirect to cart after log in if user added something to cart prior to log in

Dec 18th, 2020 (edited)
1,452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.51 KB | None | 0 0
  1. /* visit us - https://wpgenie.org */
  2.  
  3. /*
  4.  
  5. Redirect to cart after log in if user added something to cart prior to log in.
  6. This code snippet should be pasted into your child theme functions.php file.
  7.  
  8. */
  9. function custom_registration_redirect() {
  10.   if( WC()->cart->cart_contents_count > 0){
  11.           wp_safe_redirect( wc_get_cart_url());
  12.   }
  13. }
  14. add_action('woocommerce_registration_redirect', 'custom_registration_redirect', 2);
  15. add_action('woocommerce_login_redirect', 'custom_registration_redirect', 2);
  16.  
Advertisement
Add Comment
Please, Sign In to add comment