Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wooexperte/4ce611b8b0948c46bc20100fcdb2d7bf to your computer and use it in GitHub Desktop.
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
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