• Resolved heggyy

    (@heggyy)


    I have a custom order of categories for my WC products. However, the order sometimes changes by itself when I open certain categories. What could trigger this? It doesn’t always happen, seems random, but i’m not sure.

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

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Marcel Pol

    (@mpol)

    Hi,
    It is difficult for me to guess where that changes ?? Is it about the sidebar menu? I see 3 times a subcategory of “Soodus, Uus” and 1 time “Uus, Soodus”. Is that what you mean?

    And it is about categories, right? This plugin is not about the ordering of the products.

    And sometimes AJAX requests don’t get handled by this plugin.

    Thread Starter heggyy

    (@heggyy)

    Sorry, this is what I mean:

    No sorting whatsoever, just products as they should be and the categories on the left are in the correct order.

    When I apply a filter, doesn’t matter which (or click on certain categories from the left), the order changes as seen here: https://gyazo.com/ac5e4e9922252d64fcb3f9b997a82751

    The order of categories should never change.

    Plugin Author Marcel Pol

    (@mpol)

    Ah yes, that dropdown. It uses AJAX to refresh the page I suppose, and then the filtering by this plugin does not happen.

    I will see if I can do anything about that.

    Plugin Author Marcel Pol

    (@mpol)

    I was wrong ??
    It is using a WooCommerce form to order products. Changing the dropdown causes the page to refresh and have a GET parameter for orderby. This plugin doesn’t do sorting when that GET parameter is set.

    Now, I can imagine you do want this plugin to do sorting on term_order even when that GET parameter is set. But there are 40,000 installs of this plugin and I have no idea if some other websites will break then.

    It might be an idea to have this overridden by a WordPress filter, that way it can be chosen to ignore the GET parameter orderby. How do you see that?

    Thread Starter heggyy

    (@heggyy)

    I am not sure. How is it so different for me compared to other people? Is it because of the theme? Because if not, then I don’t see what’s so different for me when we all use WooCommerce.

    Dont know what to do.

    Plugin Author Marcel Pol

    (@mpol)

    Well, I don’t really know how other people use this plugin ??

    The support for the GET parameter orderby was part of this plugin before I showed up as maintainer. I can imagine people building custom stuff with that GET parameter to be able to sort categories and custom taxonomies in al kinds of ways.

    And we don’t all use WooCommerce ?? That is just one of the 100,000 plugins available. If this sorting plugin was single-aimed at WooCommerce that might be a point, but even then people might have built custom code around this GET parameter.

    So simply, I do not dare to remove that check. In the case of people that built custom term lists which can be sorted with a similar dropdown that changes the order of terms, I prefer not to break that.

    I do think that preserving the default behaviour would be a good thing, and optionally deviating from that default would be a nice option. It would only require some simple PHP code that can be documented in the FAQ.

    The tricky thing is ofcourse that an orderby GET parameter is very ambigious. Is it about post order, term order, user order, something else?
    It might be an option to break backwards compatibility and only check for a term_orderby GET parameter. But since this question is now the first I see in I think 8 years, I would prefer adding an exception to this usecase and not one supported for more than 8 years.

    Plugin Author Marcel Pol

    (@mpol)

    Oh, you don’t have to do anything yet. It is not the case that your website is broken, there is no time pressure to have this fixed speedily.
    I was interested in feedback while also speaking my mind and seeing if I can formulate things in a sensible way.

    Thread Starter heggyy

    (@heggyy)

    So, wanting the categories to stay set as they are regarldess of the filtering is not the problem, but the problem is somewhere else? Because I cannot imagine wanting what I want to be some sort of an exception.

    If I have my categories set as:
    – cat1
    – cat2
    – cat3

    why would I want them to change the order when filtering products. Nobody wants that, I think. This kind of an “error” seems weird to me for that exact reason.

    Plugin Author Marcel Pol

    (@mpol)

    Some people might want to change the order of terms based on the GET parameter for orderby with a similar dropdown with options like:
    – sort terms on popularity
    – sort terms on alphabet
    – sort terms on post count

    That is why I say an orderby GET parameter is ambiguous. You are using it to sort posts, someone else might use it to sort terms a third person might use it to order users. Ripping that check out and just giving those users the default sort order of terms even when they chose some other order in their dropdown, will be not so nice to them.

    Anyway, thanks for the feedback, it did give me input and some time to think about this.
    Version 3.3.2 is out where this default behaviour can be overridden if that orderby parameter is used to order posts, users, or anything else instead of terms.

    You can add this PHP code for your usecase, it can be added to the functions.php of your theme, or in your own plugin.

    	<?php
    	function my_customtaxorder_is_get_orderby_set( $get_orderby_set ) {
    		return false; // ignore orderby GET parameter
    		// return $get_orderby_set; // this would be default behaviour
    	}
    	add_filter( 'customtaxorder_is_get_orderby_set', 'my_customtaxorder_is_get_orderby_set' );
    	?>
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Custom category order changes when clicking on certain categories’ is closed to new replies.