WooCommerce: Redirect Empty Paginated Category Pages (404)

When managing a WooCommerce store, it’s common to rearrange products or remove them from certain categories. However, this can lead to an unexpected issue: paginated product category URLs (e.g., /product-category/shirts/page/3/) may still be accessible even when that specific page no longer contains any products.

Instead of displaying a 404 error, it’s often better to redirect users back to the main category page to avoid confusion and improve user experience.

This is especially important for SEO, as you don’t want search engines indexing irrelevant or broken pages. The solution is to detect when a paginated product category archive is empty or invalid and redirect to the base category URL instead.

Below is a simple snippet you can add to your theme’s functions.php or a custom plugin. It handles the redirect only when necessary, ensuring users and bots land on meaningful content.

Continue reading WooCommerce: Redirect Empty Paginated Category Pages (404)

Should You Redirect Your WooCommerce Shop Page to Your Only Product Category?

In a recent Business Bloomer Club discussion, a WooCommerce store owner raised an interesting question about managing duplicate content on their site. The store features multiple product categories, but the main Shop page only showcases one category.

This creates a situation where both the “Shop” and “Product Category” pages display identical content, potentially impacting SEO by creating duplicate content.

The store owner is considering redirecting the Shop page to the specific Product Category page and indexing only that page.

Let’s explore the pros and cons of this approach and provide some practical recommendations for optimizing the Shop page while maintaining the best SEO practices.

Continue reading Should You Redirect Your WooCommerce Shop Page to Your Only Product Category?

Custom WooCommerce Product URL Redirect for Better URL Structure

In a recent Business Bloomer Club Slack thread, a WooCommerce user shared a challenge with their product URL structure. The site currently uses URLs in the format website.com/product-name, but they wanted to revert to WooCommerce’s default URL format: website.com/product/product-name.

With over 900 products, manually creating redirects would be overwhelming, and they needed a solution that wouldn’t impact performance or SEO. The user also wanted to know if a snippet or .htaccess method could handle this redirect, while keeping the process efficient and clean.

To make this transition easier, a PHP snippet in WordPress can help handle the redirects automatically, avoiding .htaccess changes. Here’s how you can set it up so that product pages will redirect to the new URL structure with minimal hassle.

Continue reading Custom WooCommerce Product URL Redirect for Better URL Structure

WooCommerce: Remove “add-to-cart=123” URL Parameter After Add to Cart

The “add-to-cart” parameter in WooCommerce is used to create a custom URL that adds a specific product to the shopping cart. The “123” value is the product ID, and you can even specify a custom quantity. By clicking a link with this parameter in the URL, the user can add the specified product (ID# 123 in this example) to their cart without having to navigate to the product page itself.

The problem is that WooCommerce itself doesn’t automatically remove the “add-to-cart” parameter after a successful add to cart, and if you reload the page you will add to cart again! So, let’s see how we can remove this parameter in case you disabled the “redirect to cart” option.

Continue reading WooCommerce: Remove “add-to-cart=123” URL Parameter After Add to Cart

WooCommerce: Empty Cart Redirect

An empty WooCommerce Cart page can be frustrating for customers, especially if they’ve been browsing and adding items to their cart.

Redirecting them to a relevant page, like the Shop page, can help them continue shopping and potentially complete a purchase.

The redirect page can be used to showcase ongoing sales, promotions, or new products that customers might be interested in. This can help generate interest and encourage customers to make a purchase.

So, let’s see how we can redirect users from the empty Cart page to another page on the same website. Enjoy!

Continue reading WooCommerce: Empty Cart Redirect

WooCommerce: Redirect URL With SKU To Single Product Page

Let’s say your WooCommerce product has the following permalink: example.com/shop/t-shirts-tops-and-blouses/t-shirt-casual-v-neck-longsleeve-green-medium-cotton-stretch

Wouldn’t it be shorter, more fun and neater if you could also reach the same exact single product page by using example.com/sku00001 in the browser bar, where “sku00001” is the product SKU?

Well, in today’s snippet we will create a simple redirect from a custom URL that contains the product SKU to the product page, so that you can use the URL “shortener in your email marketing, display advertising, blog posts and anywhere you want to show a “pretty link” instead of a full, long, boring product page URL.

Enjoy!

Continue reading WooCommerce: Redirect URL With SKU To Single Product Page

WooCommerce: Redirect Product Category Pages

Maybe because you have only one product category and therefore search engines would find duplicate content (Shop page = Category page) and penalize your website.

Or maybe because you use advanced product filters and you prefer customers to see the filtered view “by category” (e.g. “example.com/shop/?_product_category=tables“) as opposed to the default category pages ( “example.com/product_category/tables” ).

Either way, it is possible to programmatically redirect all product category pages to a given page or to a relevant URL with parameters – and here’s the fix. Enjoy!

Continue reading WooCommerce: Redirect Product Category Pages

WooCommerce: Disable Single Search Result Redirect

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

WooCommerce: Single Product Page Redirect for Logged In Customers

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