Product Variations not showing up in order

I have a woocommerce site and I have a question about my product variations. Specifically, on this page: https://equineoutfitters.biz/product/back-on-track-eq3-microfiber-riding-helmet/

You’ll notice that the drop down for sizes does not list the sizes in order. 7 1/8 is smaller than 7 1/4 but it is listed after - I really want these to be listed in order from smallest to largest (so 7 1/4 should be last since its the largest). That is how I entered them in the product variation section in the backend, but no matter what I do they are listed this way on the front end.

Hello @jessparvin,

Thanks for writing in! :slight_smile:

To achieve the order of the sizes, you can add the code to X > Theme Options > JS:

jQuery(document).ready(function($) {
    $("#pa_sizes").html($("#pa_sizes option").sort(function(a, b) {
        if (a.value == "") return;
        if (a.value == 7) return;
        var a = parseInt(a.text.match(/\d+/), 10),
            b = parseInt(b.text.match(/\d+/), 10);
        return a < b ? -1 : 1;
    }));
    $("#pa_sizes option:first-child").attr("selected", true);
});

Hope that helps.

Thank you. That worked for that product. But now I have another product that I also want to list sizes from smallest to largest, but the sizes are not numbers. When I put the attributes (or variables) in the order I want them to display, it is automatically changed to an alphabetical listing. I need “pony” to be listed first and “large horse” last.
https://equineoutfitters.biz/product/best-friend-deluxe-grazing-muzzle/

Hello There,

In most case, your product attributes default sorting order is by Name. To resolve your issue, please do the following:

  • Go to Products > Attributes within wp-admin
  • Select the Attribute (e.g. Size) to edit.
  • You’ll noticed an option “Default sort order”. Select the option “Custom Ordering” so that you can drag and drop the attributes according to your desired order.
  • And Save the changes.

Hope this helps.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.