Home Forums WoodMart support forum custom Login while checkout help needed

custom Login while checkout help needed

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #243586

    I want customers to be redirected to login if the open the checkout page without being logged in. I found this solution on stackoverflow https://stackoverflow.com/a/50003749/14685541.

    So I created a page : Login to checkout
    where I put the [woocomerce_my_account] shortcode.

    And then added this code to functions.php
    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(‘login-to-checkout’) ) );

    // 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(‘login-to-checkout’) ) {
    if( is_user_logged_in() || WC()->cart->is_empty() ) {
    wp_redirect( get_permalink( get_page_by_path(‘checkout’) ) );
    }
    }
    }
    add_action( ‘template_redirect’, ‘custom_woocommerce_login_redirect_to_checkout_page’ );

    The first part worked fine, if the user was not logged in and pressed checkout then it is redirecting to the custom login page I had created (https://siristore.in/login-to-checkout)

    But,

    Once logged it is not redirecting to checkout. Instead it redirects to my account page.

    I think due to some custom php code written by xtemos this function is not happening.

    Could you please help how to figure this out?

    Thank you

    #243588

    I kept trying for additional solutions and i found this https://aceplugins.com/creating-a-login-registration-page-before-checkout/

    I created the custom shortcode and added that to Login to Checkout page and everything worked as mentioned in the above article. Although that shortocode is not responsive and doesnt have social login buttons.

    So therefore all I want is a custom shortcode for the Login/register as designed by xtemos where the submit button doesnt redirect to my account page.

    Could you please create a shortcode like that?

    I hope I am being as articulate as possible.

    Thank you

    #243635

    Hello,

    Woocommmerce suggests adding a login form into the checkout for not logged in users by default. You can find this option in Wooocommerce > Settings > Account and Privacy

    Best Regards

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)