Go to WordPress Dashboard > Products, select more than one product, and then go to the Bulk Actions dropdown and choose “Edit“.
You’re now presented with a simple yet effective bulk edit window, where you can do basic product fields editing such as changing the price in bulk, assign the same tag in bulk, set a sale price percentage in bulk, and so on. You can even assign one or more categories to the selected products.
But wait – it seems you cannot remove product categories from all selected products, which is a bummer! Well, I’m not sure if this is a WooCommerce choice, but honestly it’s such a basic thing that I’m surprised there is no bulk edit option for that.
So, let’s fix this. Let’s add a custom select dropdown with a list of product categories – whenever a category is selected, this will be removed from all checked products. Enjoy!
Continue reading WooCommerce: “Bulk Edit” > Remove Categories @ Admin Products List
The WooCommerce Single Product page, on top of letting you add to cart the current item, also displays a list of related products and up-sells (when defined).
But what if you ALSO want to show a grid of “related product categories”, so that the customer can easily navigate to a category page instead of a single (related) product?
In this experiment, we will first calculate the current product’s categories, and then use a WooCommerce shortcode to output them as a grid, right below the related products section. Enjoy!
Continue reading WooCommerce: Display “Related Product Categories” @ Single Product Page
Especially when you have many WooCommerce product categories, it may happen some of them have a single product. Although this is a rare scenario, let’s see how easy it is to redirect customers directly to the single product page in case you don’t want them to see the category page first. Enjoy!
Continue reading WooCommerce: Redirect Specific Category To Product Page
It’s easy enough in WooCommerce to get/calculate product sales. What’s difficult, on the other hand, is calculating the total amount of sales for a specific category, because there is no core function that already does that.
Why sales by category – you may ask? Well, to me, that’s a very important metric. For example, I sell both consulting and non-consulting products on this same website, so it’s important for me to keep track of category sales year-on-year, especially when my goal is reducing 1-to-1 client work while increasing scalable product sales such as courses, plugins and memberships.
In this quick tutorial, we will first get the “WooCommerce orders that contain a target product category”, and after that we will loop through the array to calculate the total sales for that specific category. Sounds difficult? No worries – just copy and paste the snippets below.
Continue reading WooCommerce: Get Total Sales By Product Category
We can get products belonging to a product category or product tag very easily. What’s much more difficult is getting single variations based on a product category or product tag, as variations… don’t have a category or tag, which belong to its “parent” variable product instead.
In this post, we will define a function that you can reuse in your custom code whenever you need to get all variation IDs based on a given product category or product tag. You can then loop through the array and return whatever info you need. Enjoy!
Continue reading WooCommerce: Get Variation IDs By Product Category or Tag
Whenever we need to do custom WooCommerce work, remembering how to get “things” is the most time-consuming task. So, a Google search often helps us find the right and quickest solution.
For example, it’s easy to “get the current product’s categories“, but how can we get the “parent product categories” only? In today’s snippet we will see how this can be achieved in 7 lines of PHP. Enjoy!
Continue reading WooCommerce: Get Product Parent Categories
We’ve already seen how to only display products from a single category on the Shop page. Today, we’ll do something similar, but we’ll target the search result.
Code is somewhat similar to the example I linked to above, so it will use once again the “pre_get_posts” filter in order to modify the query before products are returned on the screen. Enjoy!
Continue reading WooCommerce: Exclude Category from Search Results
This is an interesting WooCommerce customization – as you know WordPress menus and widgets read whatever product category name and display it in the frontend.
Let’s say your product category title is “Tables”. This will show up in the navigation menu if you have set it up that way, in te breadcrumbs if you have any, in the sidebar category widgets, and as a title on the single product category page.
This is great and all, but what if your product category name is “Red Round Tables By Whatever Brandname“? As you can imagine, displaying this in a sidebar or navigation menu may be a little too much, while it’s fine to use it as a H1 on the single product category page for SEO reasons and enhanced readability.
So, the question is – how do we define an “alternative” product category name, so that this can be used on the product category page as custom title, while using the default one for other smaller locations such as menus and widgets?
Well, this is how it’s done – enjoy!
Continue reading WooCommerce: Override Product Category Page Title
You can use a shortcode or block in order to display the WooCommerce products on sale. However, what if you wanted a proper “product category” called “Sale” – and where you didn’t need to manually assign this category to each product?
Basically, how do we display all the discounted products in a custom category called “Sale”, without doing any manual work?
Here’s a super quick tutorial. Enjoy!
Continue reading WooCommerce: “Sale” Category (Automatic)
We already saw how to show product categories in the Cart, how to display a category in the Shop page, but we never talked about showing ALL the product’s categories in the Shop / Category / Tag / Loop pages.
On top of that, we’ll also study the wc_get_product_category_list() function again, which is a super useful shortcut to get all the categories for a given product. Enjoy!
Continue reading WooCommerce: Display Product Categories @ Shop
Well, this is gonna be a big one for you. When you start having lots of products and lots of product categories, the shop page becomes either messy or unrepresentative, because it may show just the latest 16 products on page 1 when you have dozens of categories and a much wider range of products…
As usual, there are plugins for that – first one that comes to mind is Nested Category Layout by Skyverge – but today I wanted to see how doable it was to code it, and how many lines of PHP were required.
So, if you wish to switch the WooCommerce shop page display from “products” to “a given number of products for each parent category”, here’s the fix. Enjoy!
Continue reading WooCommerce: Split Shop Page By Category
Using WooCommerce product categories is one of the best ways to help your shoppers find what they need quickly and improve their experience at your store.
As a store owner, organizing products into categories will improve product discovery and business efficiency by helping you analyze sales and customer buying patterns better. Moreover, it’ll give a structure to your online store, which is a critical aspect of SEO and can help you rank higher in search results.
These points make a strong case for creating product categories in your store – the good news is that it’s also fairly simple to do this with WooCommerce.
However, the real struggle begins when you have to edit these categories – adding new products, removing items or overwriting them into a new one for example.
Performing these actions on one or two categories may not hurt, but editing a large number of them individually can be a challenge.
Luckily, there are multiple ways you can bulk edit your product categories to save on time and boost efficiency.
In this article, we’ll dive into how you can edit product categories en masse using WooCommerce’s default settings. For more advanced editing options, it’s best to go for plugins – so, we’ll also explore some great plugins you can use for this purpose.
Continue reading WooCommerce: How to Bulk Edit Product Categories
WooCommerce variable products display a price range by default, which goes something like this: $MIN-$MAX. Now, wouldn’t it be nice, on the Shop page or Category Widget, to show the price range for each category?
Well, as usual this is a customization that can apply to certain online businesses only, so hopefully you’re one of them. Either way, this is yet another chance for you to learn PHP applied to WooCommerce. Enjoy!
Continue reading WooCommerce: Product Category Price Range
Here’s yet another snippet I use on A Piece of Sicily, my Sicilian marketplace, to make sure vendors can only select one product category for a given product. This is to make sure they make the best possible choice and also to avoid confusion and multiple listing.
Of course, the same can be used on your own WooCommerce install, in case you wish to limit the number of categories that can be assigned to each product (inside the snippet, you can even change “1” to “whatever number” and therefore define your own “max” e.g. max 2 categories).
This time I can’t make you “see” the customization as we’re in the backend, so please take a look at the screenshot below. Enjoy!
Continue reading WooCommerce: Force Max 1 Category Per Product
Upon installation, WooCommerce adds a default product category called “Uncategorized”. This is a nice feature because each product must belong to at least one category, and “Uncategorized” is therefore the WooCommerce-way to avoid problems.
All good so far, until you get to the stage where you have dozens of product categories and if *one day* (everyday for me lol) you forget to assign a product to one of them your product will automatically fall under “Uncategorized”, with that category showing also on the frontend which is not nice at all.
In this post, we’ll see how to remove this “Uncategorized” category, forever. Enjoy!
Continue reading WooCommerce: Delete “Uncategorized” Product Category Forever
When you work with WooCommerce PHP snippets, you often need to “get” stuff off your WordPress database in order to make some calculations and return the result on the screen. And if there is something I often google is “How do I get all my store’s product IDs?“.
Thankfully the wc_get_products WooCommerce function gives us the answer. Enjoy 🙂
Continue reading WooCommerce: Get Product IDs (All, by Tag, by Category)
We already studied how to detect if a product ID is in the cart – but if you take a look at the comments many of you were asking how to detect product categories.
So, today we’ll do exactly that. You can disable shipping rates, payment gateways, you can print messages, you can apply coupon programmatically… there are lots of things you can do “conditionally”, based on whether a given product category is in the Cart or not.
Continue reading WooCommerce: Check if Product Category is in the Cart
While working for a freelance client I had to “detect” the cart item categories in order to apply some PHP customization.
So I thought – why not share with you how to display product categories in the Cart and Checkout? This adds a nice touch to those two vital pages, and prints a list of product categories under each cart item.
Also, I’m glad to introduce you to the amazing world of “wc_get_product_category_list“, a very handy WooCommerce PHP function!
Continue reading WooCommerce: Display Product Categories @ Cart & Checkout Pages
Today we take a look at the WooCommerce “Add to Cart” buttons. What if you wanted to change the “Add to Cart” text depending on the Product Category? For example, you may want to show “Buy Now” for books and “Add to Basket” for cds.
Continue reading WooCommerce: Edit “Add to Cart” Text by Product Category
Hello WooCommerce Customizers!
Today we take a look at the WooCommerce Shop page and specifically at how to show only the category you want (and exclude all the others). Some store owners may need this, you never know the weird questions you get asked!
Continue reading WooCommerce: Show Only 1 Category @ Shop Page