Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Marketplace (WooCommerce Multivendor Marketplace) › Redirect issues when logging in as a vendor account during checkout
- This topic has 4 replies, 2 voices, and was last updated 4 years, 6 months ago by sho_amano.
- AuthorPosts
- December 20, 2019 at 8:34 pm #98243sho_amanoParticipant
If I check the “Allow customers to log into an existing account during checkout” setting in Woocommerce, when a customer logs in as a vendor account, they are redirected to the vendor dashboard.
How can I return to the checkout page while logged in, just like a customer account?
- December 23, 2019 at 10:43 am #98633WCFM ForumMember
HI,
Please add this code to your site –
add_filter( 'wcfm_login_redirect', function( $redirect_to, $user ) { if( wcfm_is_vendor( $user->ID ) && is_checkout() ) { $redirect_to = wc_get_checkout_url(); } return $redirect_to; }, 50, 2 );
Add this code to your child theme’s functions.php
In case you do not have child theme then add code using this plugin – https://wordpress.org/plugins/code-snippets/Thank You
- January 29, 2020 at 7:58 pm #104569
- February 6, 2020 at 12:38 pm #105703WCFM ForumMember
Hi,
Please use this revised code –
add_filter( 'wcfm_login_redirect', function( $redirect_to, $user ) { if( wcfm_is_vendor( $user->ID ) ) { if ( ! empty( $_POST['redirect'] ) ) { $redirect_to = wp_unslash( $_POST['redirect'] ); } //$redirect_to = wc_get_checkout_url(); } return $redirect_to; }, 50, 2 );
Thank You
- April 28, 2020 at 10:02 pm #124367sho_amanoParticipant
Thank you so much!
The problem is solved!
- AuthorPosts
- You must be logged in to reply to this topic.