Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Woocommerce can't disable Guest Checkout

I am using Woocommerce and am having problems disabling the guest checkout.

I have made sure 'Enable Guest Checkout' is unticked in the settings page but people are still able to checkout without creating an account or logging in.

Is there somewhere else I should be setting this?

like image 200
fightstarr20 Avatar asked Oct 21 '22 03:10

fightstarr20


2 Answers

Go to WooCommerce > Accounts and untick Enable registration on the "Checkout" page.

This should do the job!

screenshot

Alternatively, you can add this code to your theme functions.php

add_action( 'template_redirect', 'woo_restirct_checkout' );
function woo_restirct_checkout() {

    if ( !is_user_logged_in() && is_checkout() ) {

        $my_account_url = get_permalink( get_option('woocommerce_myaccount_page_id') );
        wp_redirect( $my_account_url );
        exit;

    }
}

Cheers, Francesco

like image 160
FrancescoCarlucci Avatar answered Oct 24 '22 00:10

FrancescoCarlucci


Also need to unticked the option from Woocommerce -> Accounts tab. Where it says Enable registration on the "Checkout" page.

like image 43
Purva Bathe Avatar answered Oct 24 '22 00:10

Purva Bathe