You have a WooCommerce product called “VREIUTERTKXYU“. You search for “VREIUTERTKXYU” (exact match). WooCommerce, by default, redirects you to the single product page as there is only 1 possible search result (as opposed to sending you to the search result page).
In today’s tutorial, we will be deactivating this WooCommerce function and go back to the normal (at least, to me) behavior: even if there is an exact match in a search (single search result), we still want to display the search page.
The screenshot that follows gives you a working proof, once the snippet you find below is active. Enjoy!
Continue reading WooCommerce: Disable Single Search Result Redirect
It’s nice to know the stuff I share here is used on my own website! In this case scenario, I have a custom “My Courses” tab under the My Account navigation menu; instead of showing the My Account tab content with a link, I want to save time and immediately redirect users to https://www.businessbloomer.com/woocommerce-online-courses/ instead.
So, how do you redirect My Account tabs to custom URLs? Well, thankfully it’s just a matter of a few lines of code. Enjoy!
Continue reading WooCommerce: Redirect My Account Tab to URL
We’ve already seen how to set a custom My Account login redirect URL by user role – but today we want to cover another case scenario: redirecting users to the previous URL (referrer) after logging in from the My Account page.
Actually, WooCommerce already prints a hidden input field (“_wp_http_referer“) in the login form thanks to wp_nonce_field(), but for some reason this is not enough to allow the actual redirect.
Thankfully, the WooCommerce process_login() function provides another workaround: if $_POST[‘redirect’] is set, the form will consider redirecting to this URL instead of the default My Account Dashboard! This means we can simply add a new hidden field to the login form with that exact name (“redirect”), so that we can make that function trigger the redirect we want.
Easier coded than said, so let’s see how it’s done. Enjoy!
Continue reading WooCommerce: Login Redirect to Previous URL @ My Account
There are times when you don’t want customers to login and be redirected to the default “My Account” dashboard. Maybe because you have a membership site and you want them to go to a custom “Welcome” page, or maybe you wish to send them straight to their “My Account” > “Downloads” subsection.
No matter the why, for sure figuring out how to achieve a custom redirect once a user logs in from the “My Account” page is quite straightforward. The hook we’ll use is called “woocommerce_login_redirect” and allows us to trigger a safe redirect whenever a customer clicks on the LOGIN button. Enjoy!
Continue reading WooCommerce: Login Redirect by User Role @ My Account
If you sell one-off products like online courses, lifetime memberships or unique pieces that can only be purchased once by a given customer, maybe you’d better redirecting the logged in customer who has purchased that product to a custom URL, such as the shop page, the “my courses” page for online courses or another customer-specific section.
With this easy snippet you’ll learn how to see if a user is logged in and has purchased a given product ID and then how to do a safe PHP redirect. Enjoy!
Continue reading WooCommerce: Single Product Page Redirect for Logged In Customers
Here’s how to create custom WooCommerce Add to Cart HTML links / buttons and make them add a given quantity of a single product to cart and redirect to specific website pages.
This tutorial explains how to achieve that for simple products but also variable and grouped types.
I strongly recommend to read through all the post comments in case you’re not sure about something – many people have asked the same questions over and over again e.g. “is it possible to add more than 1 product to Cart?” (to which the answer is “no”, unless you create a Grouped Product).
With this guide it’s much easier to place Add to Cart buttons on custom landing pages, pricing tables, blog posts and so on. Enjoy!
Continue reading WooCommerce Custom “Add to Cart” URLs – The Ultimate Guide