In this post, we ate going to learn about woo-commerce get logout URL and let’s make that step by step
First: get the my account page id by using the code get_option( ‘woocommerce_myaccount_page_id’ );
Second: check if there is any my-account page id
Third: get the permalink bypassing my account page id through the function get_permalink( $myaccount_page_id )
Fourth: now get the logout URL bypassing my-account URL through the function wp_logout_url( get_permalink( $myaccount_page_id ) )
Fifth: Check if there is SSL checkout
Sixth: now replace Http: to https:
Now you can print the logout URL
Here is the code to get a woo-commerce logout URL.
<?php $myaccount_page_id = get_option( 'woocommerce_myaccount_page_id' ); if ( $myaccount_page_id ) { $logout_url = wp_logout_url( get_permalink( $myaccount_page_id ) ); if ( get_option( 'woocommerce_force_ssl_checkout' ) == 'yes' ) $logout_url = str_replace( 'http:', 'https:', $logout_url ); } ?>
Thanks for Reading