WooCommerce Redirects – Override Redirect for Product

February 7, 2018

Yesterday, a customer sent me a message wanting to know how she could conditionally modify the redirects she set for her products using Custom Redirects for WooCommerce. I thought this would be a good topic for a quick tutorial, so I put together a simple code snippet for accomplishing just that.

In this code, we’re first checking to make sure we’re only applying it to add-to-cart-redirects (not after-purchase redirects). Then, we’re retrieving a store’s cart URL, and referring URL (URL of customer’s previous location). We check to see if these URLs are the same, meaning if the last page the user was on was the cart page. If a product is added from the cart, we want to redirect the user back to the cart (keeping them in the cart), rather than applying the redirect that was set for the product.

You can post this code to your theme’s functions.php file, or to a function plugin. Just make sure to pay attention to the <?php at the top.

That’s all there is to this one. Feel free to post any questions in the comments!

Creating a Sales Funnel in WooCommerce

Creating a Sales Funnel in WooCommerce

According to Keap: A sales funnel is the marketing term for the journey potential customers go through on the way to purchase. There are several steps to a sales funnel, usually known as the top, middle, and bottom of the funnel, although these steps may vary...

read more
Redirects in New Tabs and Product Variations

Redirects in New Tabs and Product Variations

The Custom Redirects for WooCommerce was just updated! The latest version, 2.3.0, now includes two of the most requested features. Opening Redirects in New Tabs Now included is a setting that, when enabled, opens a redirect in a new tab when the "Add to cart" button...

read more
Custom Redirects for WooCommerce Version 2.1

Custom Redirects for WooCommerce Version 2.1

Custom Redirects for WooCommerce was just updated to version 2.1.0. The update includes support for after-purchase redirects. Instead of just being able to redirect users when they add a product to their cart, you can now redirect the user when they actually purchase...

read more
Join

Start Your Sales Funnel Today!

Join what thousands of other sites are doing, and set up your WooCommerce sales funnel today.

The Comments

2 Comments

  1. jim

    how can we make the redirect to happen faster? i put redirect to custom page but when the visitor hit the add to cart button it takes a while

    Reply
    • Ren

      It sounds like the redirect location may not be the quickest in terms of page speed or load times. If the redirect is still to your website, you can probably improve load times with some optimization work. If the redirect is to some external website, the page speed would be out of your control.

      Reply

Submit a Comment

Your email address will not be published.

Heya, stranger!

Purchasing software isn't always easy. Here's something for you that will hopefully make it a little easier...

Expiring Soon

Get it while it lasts...

Spin up your sales funnel with ease...and for cheap! Here's a 20% discount to get you started.

days
hours
minutes
seconds