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

WooCommerce: Custom Add to Cart URLs – The Ultimate Guide

In WooCommerce you can add a product to the cart via a custom link. You just need to use the “add-to-cart” URL parameter followed by the product ID.

This tutorial will show you how to create custom URLs to add simple, variable and grouped products to the cart – as well as defining the add to cart quantity and an optional redirect.

You will be able to see each possible scenario, and also copy/paste the custom URLs so that you only need to replace product IDs and quantities.

I strongly recommend you 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 the cart?” (to which the answer is “no”, unless you install a custom plugin) or “Why does my product get added twice?

With this guide it’s much easier to place WooCommerce add to cart buttons on custom landing pages, pricing tables, blog posts, external websites, and so on. Enjoy!

Continue reading WooCommerce: Custom Add to Cart URLs – The Ultimate Guide