Created
November 22, 2018 14:55
-
-
Save wooexperte/4ce611b8b0948c46bc20100fcdb2d7bf to your computer and use it in GitHub Desktop.
WooCommerce Snippet - Vor dem Kauf automatische Weiterleitung auf die Seite "Mein Konto" zur Anmeldung oder Registrierung
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('template_redirect', 'woocommerce_custom_redirections'); | |
function woocommerce_custom_redirections() { | |
// Kunde nicht angemeldet oder registriert. | |
if ( !is_user_logged_in() && is_checkout() ) | |
wp_redirect( get_permalink( get_option('woocommerce_myaccount_page_id') ) ); | |
// Kunde registriert und angemeldet | |
if( is_user_logged_in() && ! WC()->cart->is_empty() && is_account_page() ) | |
wp_redirect( get_permalink( get_option('woocommerce_checkout_page_id') ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment