• Hi,

    I have strange bahevior of your plugin in my e-commerce. I have almost 600 products in my store and I’m using your plugin to make DESC order for all products by “title”. And it runs well, but, few items don’t fit the order.

    https://armin.nodesk.pl/kategoria-produktu/18-urodziny/

    here you can see That the order of GIFT-M products is:

    GIFT-M-99 GIFT-M-98 GIFT-M-97 GIFT-M-96 GIFT-M-95 GIFT-M-94 GIFT-M-93 GIFT-M-92 GIFT-M-91 GIFT-M-59 GIFT-M-48 GIFT-M-26 very good till now, but the next item is: GIFT-M-102, then GIFT-M-101, GIFT-M-100 and again GIFT-M-09

    So what’s the problem with 100’s? Why they don’t fot the order?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author SkyVerge

    (@skyverge)

    Hey @nodesk,

    Thanks for reaching out to us! Happy to help out here. ??

    It seems to me as though it’s viewing something with 100 as a suffix (so GIFT-M-102) as starting with a 1, which is lower than a 2 like 26.

    I’m able to replicate this on my local site with the latest version, so I’m going to open up a bug report for this. While I’m not sure when this will be fixed up, my team will be made aware of it shortly.

    Is there anything else I can help out with here? Please don’t hesitate to let me know.

    Thanks!

    Julie ??
    SkyVerge

    Thread Starter nodesk

    (@nodesk)

    Great, do you need source files? ??

    Plugin Author SkyVerge

    (@skyverge)

    Hey @nodesk,

    No, that’s all right, and thank you for the offer. ??

    I filed the bug report and then got to talking with some of my colleagues about this.

    Ultimately, this is a technical limitation with MySQL and the way WordPress queries work.

    MySQL cannot sort alphabetically and numerically at the same time. If sorting alphabetically (or reverse, like Z-A), then that’s how it’ll be sorted and you’ll get 1, 10, 100, 2, 20, 200, 3, 30, 300 and so on and so forth.

    This can be overcome with custom sorting, though we rely on WP_Query, which is WordPress’ default way to retrieve posts. Our plugin changes how things are sorted in that query, which is how we can offer more options than the default.

    That said, we’re still using WP_Query, which doesn’t have that kind of sorting built into it. If you’re interested in the technical details, you can take a look at these resources:

    WordPress Query: Order & Orderby Parameters

    StackExchange: WP Query orderby meta key natural sort?

    All of this is to say that, due to our use of the WP_Query class, we’re unable to fix this limitation at this time, I’m afraid. However, if this is really important to you, you could work with a third-party developer to add that custom sorting for your specific use-case.

    Another option is perhaps renaming things to be number-first and then sort numerically, so you get:

    101-GIFT, 100-GIFT, 26-GIFT

    I hope that helps to explain why we’re not able to fix this up at this time. I’m sorry I don’t have better news here.

    Is there anything else I can help out with? Please don’t hesitate to let me know.

    Thanks!

    Julie ??
    SkyVerge

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Strange behavoior’ is closed to new replies.