Product Attributes not sorting by Term ID
-
Hi there
I’ve created a global attribute on my website called “Sizes”, and for this attribute I have selected to order all terms by Term ID. I am uploading all sizes that I will be using on my website using Python and the Woocommerce REST API. I can upload the sizes from my Python Script to my website, but the website isn’t ordering the Sizes according to Term ID.
Instead, order by Term ID is ordering the Items exactly the same as Ordering them by Name.
Has anyone had a similar problem to this and does anyone know what is causing this? Have I misunderstood what is meant by “Sort by Term ID”? There are a few caveats to add:
1) I am sure that my Term ID is correct. I upload the sizes in a specific order, and thus WooCommerce assigns a Term ID based on the order that they are uploaded to the website. I can verify what the Term ID is for each “Size” by either viewing them in the SQL Database, or by using the API to retrieve, and I can confirm they are not in the Term ID order, either ascending or descending order. Instead they are sorted via Name
2) I have a feeling people might suggest using a custom sort instead. However, I’m reluctant to do this because I will have probably over 200 sizes to sort, and I would like to replicate the sizes and ordering to additional websites so it would be better for me to have one script that I could deploy to each website to then get the sizes uploaded in right order.Finally, to show you what is happening, here are the sizes and order I am uploading to the website:
Sizes in the order I’m Uploading
“Newborn”, “3 Months”, ‘6 Months’, ‘9 Months’, ’12 Months’, ’18 Months’, ‘2 Years’, ‘3 Years’, ‘4 Years’, ‘5 Years’, ‘6 Years’, ‘7 Years’, ‘8 Years’, ‘9 Years’, ’10 Years’, ’11 Years’, ’12 Years’, ’13 Years’, ’14 Years’, ’15 Years’, ’16 Years’, ’17 Years’, ’18 Years’, ‘XXS’, ‘XS’, ‘S’, ‘M’, ‘L’, ‘XL’, ‘XXL’, ‘XXXL’Order sizes are appearing in the Attributes Section
10 Years, 11 Years, 12 Months, 12 Years, 13 Years, 14 Years, 15 Years, 16 Years, 17 Years, 18 Months, 18 Years, 1test, 2 Years, 3 Months, 3 Years, 4 Years, 5 Years, 6 Months, 6 Years, 7 Years, 8 Years, 9 Months, 9 Years, L, M, Newborn, S, testalpha, XL, XS, XXL, XXS, XXXLNote I added in 1test and testalpha directly through Woocommerce just to see if these would be added to the end of the list if I retained “Sort by Term ID”, they didn’t and were added into the section alphabetically according to “Sort by Name”.
Just to add to this, if I pull up the term details for the size Newborn and 10 Years, it shows the following:
Newborn
{‘id’: 532, ‘name’: ‘Newborn’, ‘slug’: ‘newborn’, ‘description’: ”, ‘menu_order’: 0, ‘count’: 0}
10 Years
{‘id’: 546, ‘name’: ’10 Years’, ‘slug’: ’10-years’, ‘description’: ”, ‘menu_order’: 0, ‘count’: 0}I’ve also tried creating a menu order using the REST API to assign a specific value and then changing the Sort order to Custom but this did nothing either.
So, not sure if this is a bug or a feature, but if anyone could let me know then that would be great. I’m using WooCommerce V4.3.1
Thanks
- The topic ‘Product Attributes not sorting by Term ID’ is closed to new replies.