• Hi,
    I wanted to ask for a help with understanding if it is possible to get the posts and keep the order I have set with the plugin.
    I tried to add the orderby: “menu_order” on my query but it orders the products in a completely different way.

    This is a React app and I am using “react-native-woocommerce-api” module to fetch the products.

    Any help would be much appreciated!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    tried to add the orderby: “menu_order” on my query but it orders the products in a completely different way.

    By default the manual order does not override an existing orderby directive on the query. Try without any orderby attribute in your query or alternatively you can force the override with the checkbox option in the ReOrder admin page.

    Make sure your query does not suppress_filters

    This is a React app and I am using “react-native-woocommerce-api” module to fetch the products.

    do you control the query? I know that WooCommerce tends to suppress certain filter options, so try to retrieve your products with a plain wp_json REST request on the product post type to see if you can retrieve the correctly ranked list of posts.

    Let me know either way, would be interesting for others to get this to work.

    Thread Starter webziss

    (@webziss)

    Thank you for your reply.
    I now understand that my issue is quite different from what I thought, I am retrieving the products by specific categories array of ids, this is because I have to exclude some categories in my app before I get the products, so at the end the list of products I get are from multiple categories and not only 1. So my query looks something like that:

    const params = {
      per_page: "100",
      status: "publish",
      category: [16,31,25],
    };



    I am wondering how can I find a workaround for that without adding too many API calls…

    Plugin Author Aurovrata Venet

    (@aurovrata)

    There are 2 ways you can achieve this, but in both case you’ll need to build a custom api end point to retrieve multiple categories with manual ranking.

    1. you can handle the ranking on the server, use a custom function to retrieve a list of posts for each category terms, combine them and send it to your app.
    2. in addition to what you are currently doing, you can instead retrieve the ranked post IDs of each term you need. These are stored as post meta fields for each term ID, and can be retrieved a custom SQL query. You can see it in action in the file admin/class-reorder-post-within-categories-admin.php on line 527.
    Thread Starter webziss

    (@webziss)

    Thank you Aurovrata Venet, those solutions didn’t work for me but I will try to figure it out.

    Really appreciate your help!

    Plugin Author Aurovrata Venet

    (@aurovrata)

    Sorry to read you. I haven’t worked on RESTful ranked post queries. If you need a solution and your project can afford it, you may consider sponsoring this feature on the plugin. Either way, do keep me posted if you find a solution.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Keep products order after API fetch’ is closed to new replies.