• Resolved photogenic

    (@photogenic)


    When creating custom columns in Admin on Analytics/Customers, it was not possible to make those sortable. The browser returns an error when trying to click and sort them. How can I make them sortable / orderby?

    THIS IS WHAT I TRIED SO FAR

    When adding custom column to the table header through the js filter woocommerce_admin_report_table, you can give the new column header object the property isSortable: true. Once this has been done, and one tries to sort by the custom column, it shows the error “There was an error getting your stats. Please try again.”. The api fetch returns a 400 because the “orderby” parameter for Customers only allows the defaults: username, name, country, city, state, postcode, date_registered, date_last_active, orders_count, total_spend, and avg_order_value.
    Those defaults are defined in an array in the method Automattic\WooCommerce\Admin\API\Reports\Customers\Controller->get_collection_params(). There is no filter at any point in the request chain to change those parameters, making it impossible to alter the data. At least I could not find anything. Or is there any way to alter the paramters of the wc-analytics/reports/customers endpoint?

    ADDITIONAL CONTEXT

    WooCommerce customer support suggested using the backend filter woocommerce_analytics_customers_query_args.
    Adding a specific column key to “orderby” unfortunately makes it impossible to switch sorting between different columns.

    • This topic was modified 10 months, 1 week ago by photogenic.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hey, @photogenic!

    While we can’t provide support for code customization as per our support policy, if you need customization, we do our best to offer advice and direct you to appropriate resources.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there too.

    I’m going to leave it open for a bit to see if anyone is able to chime in and help you out further.

    Have a wonderful day!

    Thread Starter photogenic

    (@photogenic)

    WooCommerce provides the javascript filter woocommerce_admin_report_table, which gives one the possibility to add your own columns. isSortable is one of the properties you can use when adding a column header object in this filter. Then WooCommerce also provides filters to alter the MySQL query in the backend.

    So I’m wondering, if I’m missing something in the source code. Maybe a filter somewhere. Because why would you give users this customisability while not providing entry points for one of the most basic adjustments like sorting?

    Hi there @photogenic ??

    Please note, due to the nature of this inquiry, it is best that an enhancement/feature request is submitted via GitHub, from the screen linked here, instead, in order to get better visibility from the developers of the project.

    I trust that points you in the right direction, but if you have more questions, let us know.

    We’re happy to help.

    • This reply was modified 10 months, 1 week ago by anastas10s. Reason: typo
    Thread Starter photogenic

    (@photogenic)

    Hi @pepe

    I already had created an inquiry on github, which was ignored so far: https://github.com/woocommerce/woocommerce/issues/43776

    So when writing to customer support on woo.com, I was told about using this support page.

    If someone can point me to a filter/action, to alter the analytics/customer rest route or how to change the rest route parameters, I’ll be happy to do the work myself. It’s just that the documentation is lacking and the source code is intricate, so It is hard for me to find a point where can I enter my code.

    Hi there @photogenic ??

    Thank you for reaching back, with further details on this.

    I went ahead with checking out the GitHub issue, and it appears it was already triaged.

    For assistance with customization or development with your site, we recommend that you seek help from:

    If you are comfortable coding yourself and have questions, I would also recommend that you consider:

    I hope that helps you to figure it out.

    Feel free to get back to us if you have further questions.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Make custom columns in Analytics sortable’ is closed to new replies.