WooCommerce check and redirect to login before checkout

woocommerce force login before checkout
woocommerce login before add to cart
woocommerce you must be logged in to checkout.
woocommerce login redirect
woocommerce my account dashboard redirect
woocommerce redirect before checkout
woocommerce create account on checkout
woocommerce login checkout

The default Woocommerce checkout behavior breaks a lot of web conventions by showing the "Create Account" boxes on the checkout page if it detects the user is not logged in. New users may not know what to do without any added instructions.

My desired sequence would be:

User Checkout > Check login >

  • Proceed to checkout if logged in.
  • Redirect to login/register page if not logged in > proceed to the checkout page.

This is EXACTLY the case in WooCommerce login redirect based on cart

However, what I feel uncomfortable is that, in the above case, once the user logged in, he/she will be redirected to the checkout page if the cart is not empty. If the user's cart is not empty, he/she will not be able to go to MyAccount at all even though he/she does not want to checkout yet.

Any idea on this one? Thanks in advanced everyone.

In the second answer there is a problem, after loging in the user always redirects checkout page, it does not stand on my-account page until the cart become empty!! Here is the Solution with DEMO. This code redirects the user to my-account page for login instead of checkout if the user is not logged in, then after loging in it automatically redirects to checkout page. STEP 1: Add this code in function.php

add_action('template_redirect','check_if_logged_in');
function check_if_logged_in()
{
    $pageid = 68; // your checkout page id
    if(!is_user_logged_in() && is_page($pageid))
    {
        $url = add_query_arg(
            'redirect_to',
            get_permalink($pagid),
            site_url('/my-account/') // your my acount url
        );
        wp_redirect($url);
        exit;
    }
}

STEP 2: Add this code at the end of /wp-content/plugins/woocommerce/templates/myaccount/my-account.php

<?php
$quark_web_solution_redirect = $_GET['redirect_to'];
if (isset($quark_web_solution_redirect)) {
echo '<script>
window.location.href = "'.$quark_web_solution_redirect.'";
</script>';
}
?>

This post is from developer of Quark Web Solution. Thank You!!

Creating a Login/Registration Page Before Checkout, Login/Registration form that will show before checkout. Tweet · Share. Requiring customers to login or register before checking out may sound <form class="​woocommerce-form woocommerce-form-login login" method="post"><?php Redirect guest users to login/register before completing a order. */. One of the most common WooCommerce redirects is the redirection of the user after the checkout payment. By default, they are redirected to the ‘thank you’ page.If you are looking for a solution for WooCommerce redirect after checkout; this post will guide you on how to implement the WooCommerce user redirect after checkout to a custom page.

Add this code in function.php

add_action('template_redirect','check_if_logged_in');
function check_if_logged_in()
{
    $pageid = 68; // your checkout page id
    if(!is_user_logged_in() && is_page($pageid))
    {
        $url = add_query_arg(
            'redirect_to',
            get_permalink($pagid),
            site_url('/my-account/') // your my acount url
        );
        wp_redirect($url);
        exit;
    }
}

WooCommerce Login Redirect – WordPress plugin, Custom redirect after registration/login in WooCommerce plugin. You have to install WooCommerce plugin. Redirect function will work when the user will use  WooCommerce Redirect to Checkout when a Product has been Added to the Cart. Simple and complete solution on how to configure your WooCommerce store, so the customers can skip the cart and go straight to the checkout page.

after reading this post and others in Stackoverflow, i came up with a simple solution (more than i thought at first) that is working for me... Maybe theres something i have missed up in the process, but i have tested several combinations and it works for me. So we want to:

  1. Customer goes to checkout
  2. If Logged In, continue to checkout. If not logged in, go to a page with login and register forms.
  3. Once in this page, if customer logs in or register, continue to Checkout.

First, i created a custom page with [woocommerce_my_account] shortcode. Here i customized the texts etc... in the forms, so its a little bit different that my account page. URL path of this page is -> /iniciar-sesion-registrarse.

Then, i put this code in functions.php of my child theme:

function custom_woocommerce_login_redirect_to_checkout_page() {

  // Caso 1: Usuario no identificado intenta acceder a Finalizar Compra
    if ( !is_user_logged_in() && is_checkout() )
        wp_redirect( get_permalink( get_page_by_path('iniciar-sesion-registrarse') ) );

  // Caso 2: Si en la página de identificarse, el cliente ha accedido o se ha registrado, o tiene el carrito vacío, continuar a Finalizar Compra.
  if ( is_page('iniciar-sesion-registrarse') ) {
    if( is_user_logged_in() || WC()->cart->is_empty() ) {
        wp_redirect( get_permalink( get_page_by_path('finalizar-comprar') ) );
  }
  }
}
add_action( 'template_redirect', 'custom_woocommerce_login_redirect_to_checkout_page' );

So in Case 1: If user is not logged in and tries to go to checkout, it redirects to my custom login page 'iniciar-sesion-registrarse'. Then in Case 2: If user loggin or register in this page, normal my account page would be displayed in this page, then i redirect users who are logged in and are in this page to checkout. I also redirect them to checkout if someones access this custom page directly and has nothing in their carts (so woocommerce message: u cant checkout without items in ur cart is displayed).

This way, while loggin in or registering in this custom page, error messages will display normally as if it was real 'my-account' page, but once logged in, it will redirect to checkout.

I hope someone can tell me if i have missed something in the process. Thx

Redirect to login when browsing Woocommerce pages, Search forums. Support » Plugin: WooCommerce » Redirect to login when browsing Woocommerce pages I used this and it worked to redirect my shop page, cart and checkout to the my account page login: You can check it out here:. Woo Button Text: With this plugin, you can set a custom Add-to-Cart button text for single product page and shop page, and also provides a customization option for Place Order button on the Checkout page. Not just this, the plugin also allows you to change the color and style of the button(s). Download the free plugin.

Actually had this problem today & now have a solution.

Context: our site has a separate user registration system than WooCommerce, so we didn't want a duplicative process prompting users to signup twice.

First I'll give the brief solution then list the full steps for my situation.

Brief solution: enable guest checkout, (trust me) enable account creation during checkout, automatically generate username and password (most important). Then disable in email settings the "New Account" message. Now "users" can checkout with account details auto-generated, but they never know about it and that information is essentially dumped.

Screenshot of my Accounts & Privacy settings. Please note I also disabled the "New Account" message triggered in the Email settings for WC.

Redirect customer to login if not logged in when proceeding to , I'm trying to redirect customers, who are not logged in, when they push the "​proceed to checkout button" on my cart page but nothing happens. 1. WooCommerce Settings to allow for Redirect to Checkout on Add to Cart. Go to WooCommerce > Settings > Products > Display and disable both options: “Redirect to the cart page after successful addition” & “Enable AJAX add to cart buttons on archives”:

Redirect Users After WooCommerce Login or Registration, add_filter( 'woocommerce_login_redirect', 'iconic_login_redirect' );. First of all, we'​re checking whether the attempted redirect is for the checkout  add_filter ('woocommerce_login_redirect', 'iconic_login_redirect'); First of all, we’re checking whether the attempted redirect is for the checkout page; this catches users who are logging in at checkout, as it’s likely they will want to go back there and not some other page on the site.

WooCommerce Login for Customers: The Ultimate Guide, Public WooCommerce store with guest checkout – This is the most Check out this free Helpie WooCommerce FAQ plugin which helps to Tip: If you want to control where users are redirected after they login, try Peter's Login Redirect. How to force WooCommerce customers to login or register before  Whether you want to disable login / registration on the WooCommerce Checkout page or move the login form from the top to the bottom of it, this is a simple thing to do. You can do it via a PHP snippet or WooCommerce settings. Solution 1: Remove Login/Registration @ Checkout Page. Just untick/uncheck the fields in red.

Woocommerce check and redirect to login before checkout Jobs , Search for jobs related to Woocommerce check and redirect to login before checkout or hire on the world's largest freelancing marketplace with 17m+ jobs. WooCommerce Direct Checkout aims to simplify the checkout process, leading to an immediate increase in sales. This plugin for WooCommerce allows you to redirect users to the checkout instead of cart page, change the text and link of the added to cart alert and include the ajax add to cart button in the products pages.

Comments
  • The above redirects unlogged-in users to MyAccount after login, in the middle of a transaction. How about: When users click on "Checkout" (the "checkout" button will pass on a value to indicate users clicked on the "checkout" button) --> check log in or not, AND pass on another value if "checkout value" detected; --> redirect to form-login.php if users not logged in; --> form-login.php detects "checkout value; --> IF "checkout value" not null --> checkout page; ELSE means users come from other links with no "checkout value" -->MyAccount Page. I am not sure how this can be done.
  • I happened to find another question similar to mine in: stackoverflow.com/questions/37200254/… . But I tried and it doesn't work. Anyone has any thoughts? Thank you in advanced.
  • If u are using cache plugins, make sure to never cache this custom login page.
  • A WARNING NOTE TO ALL READERS: when someone online tells you to "Trust me", please be on your guard and use your common sense before you act on that. I am keeping this answer now just for educational purpose to make all readers aware that there are people out in the open who always use your innocence to their advantage to do bad things. This is a case in point.