Believe it or not, there really are evils with alphanumeric sorting. Read on to find out how WooCommerce does or does not handle product sorting very well.
Alphanumeric Sorting – The Root of All Evil
Well – maybe not the root of ALL evil. But hey. I digress.
The Root of the Problem
When we started Sunriver Metal Works in 2013, we thought there was no way possible we could ever create one thousand unique products. Well, we were wrong.
So, where exactly does that create problems?
When we set up the current website, we used WooCommerce as our E-commerce plug-in in WordPress. We didn’t need to create a storefront. We simply were going to add a product record for each unique product we designed and created.
We figured that we would at least create 100 products. Therefore, we needed to have a 3-digit unique number to identify the products. SMWnnn – nnn represents the number. So that would mean we could create products numbering from SMW001 to SMW999.
And when we reached product SMW1000, we didn’t give it a second thought. Until we started looking at how the products were sorted in our website menus.
WooCommerce uses alphanumeric sorting in all of their “number” fields. What this means is that our product SMW1000 now displayed BEFORE product SMW099, but AFTER product SMW100. So our most current products would be buried way down in our earlier (less custom) products.
If you try to find a fix for this issue in WooCommerce, you’ll find many discussions. But the answer is always “sounds like a good idea.”
How We Solved The Problem
First, Pat had to look at how the sorting was taking place with our Product Title and SKU code. After experimenting a bit, she decided that adding a “0” in front of each Product with 3 digits would make the alphanumeric sort work properly.
So this last weekend, Pat spent nearly 4 hours updating EACH product on the website. The Product title and the SKU code needed to be changed, as both are used for sorting on the website.
It took a bit, but the website is now operating as it should be. And, we have decided that there is no way we will ever create 10,000 products. And, we were reminded of some of the truly unique products we’ve created over the past seven years.
So look for new blog posts in the upcoming months that feature some of these interesting pieces.
But until then – we’ll leave the website browsing up to our customers!