Make custom columns in Analytics sortable
-
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.
- The topic ‘Make custom columns in Analytics sortable’ is closed to new replies.