WooCommerce Redirect Product Links On Archive Page

WooCommerce product redirecting to custom URL

Pre-Requisites

There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About this Solution

This snippet stops the user from being able to the view the single product template and instead redirects them to a user defined URL. In this specific example, we redirect users to our guides page if they try to view any product page. This may be useful if you require customers to fill out a form, login to their account, or complete some other action before being able to view a product.

				
					/**
 * Snippet Name:	ecommercehints.com
 * Snippet Author:	WooCommerce Redirect Product Links On Product Archive
 */

add_action( 'template_redirect', 'ecommercehints_redirect_product_links', 10 );
function ecommercehints_redirect_product_links() {
    if (!is_product()) return;
    wp_redirect( 'https://ecommercehints.com/guides' ); // redirect to this URL.
    exit();
}
				
			

Snippet Benefits

  • Redirect product pages to custom URLs
WooCommerce Conversion Rate Optimisation (CRO) eBook
100 WooCommerce Conversion Rate Optimisation Tips

Leave a Reply

If you are going to write code in the comments, please wrap it between code tags.

Your email address will not be published. Required fields are marked *

Other Recent Guides

Subscribe To Emails

Get exclusive WooCommerce tips that I only share with email subscribers

Join hundreds of other subscribers