Skip Navigation

[Resolved] Display custom sort order for WooCommerce attributes in front end

This support ticket is created 3 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by Marcel 3 years, 1 month ago.

Assisted by: Shane.

Author
Posts
#1979661

In WooCommerce, you can add attributes to products. You can drag & drop those attributes in the order you want.

However, when I include an attribute as a custom search filter, I can't seem to select that custom order as an ordering option...

#1979779

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Marcel,

Thank you for getting in touch. The custom sort order you are referring to, is it to sort the products or are you referring to sorting the custom field filter options.

Please provide some clarity on this one so that I can best advise.

Thanks,
Shane

#1979835

Hi Shane, I'm referring to the filter options. Let's say I have the following options.

1
2
3
12
24

Then they should display in that order. But now, they display in this order:

1
12
2
24
3

#1979843

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

ordering option.PNG

Hi Marcel,

These filters are checkboxes or are they select fields ? Also are you using Blocks to create the search or the Classic editor. E

The reason is because you can specify the order in which your filter's options are being displayed. See my screenshot

For the blocks based search simply click on the filter to edit it and on the right hand side of your window you should see the options to edit the field. Just select the ordering you want from there.

If you're still unsure you can provide me with a screenshot of the filter on the backend and highlight it so that I can have a better understanding of what exactly we are handling.

Please let me know if this helps.

Thanks,
Shane

#1979911

Hi Shane,

Please see this screen recording: hidden link.

#1980153

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Marcel,

I've escalated this to our 2nd tier supporters for further checks. However I do suspect that it is a case that the sort is being done as a string but you have decimal values as a part of that list to sort.

Ofcourse a sort like this will fail, so checking with our 2nd tier team to see what can be done in this case.

Thanks,
Shane

#1982587

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Marcel,

Our 2nd tier team has made a request to our developers to have this as a feature, however I cannot guarantee that this will be implemented and if the feature is approved I cannot say when it will be added as well.

Right now the only solution is to use the function below.
https://developer.wordpress.org/reference/hooks/terms_clauses/

This function can allow you to modify the orderby name clause and allow it to sort numerically rather than a string. If this is something that you're unsure of how to implement then I would recommend that you contact a developer for them to have a look and implement it for you.

You can get in touch with the registered contractors from our site by going to the link below.
https://toolset.com/contractors/

Thanks,
Shane

#1983707

Hi Shane,

I found another workaround. I renamed the slugs. So the slug for size 3 is now 030, and the slug for size 3.5 is now 035. That way, I can sort on the slug. 030 and 035 come before 10, 20 etcetera, so that works for now.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.