Sort Order History By Custom Fields
As of 10.01.00 you can now sort the order history list page (ORDH) by additional fields including Order Number, Status, Total, Data and any custom order field.
There are now additional options in the default sort setting to set the default view customers see on their order history list.
Custom Fields
In addition, custom order fields can be assigned to the page which will allow you to output them in the template code.
First Assign the custom fields you want access to the page:
They can then be accessed by the following template code:
Custom Field Name:
Custom Field Values:
In this example, order_ip is the custom order field code.
To view the Order History List screen, login as a customer, go to My Account and click on Order History.
As an example, let’s say we wanted to add a user sortable column to this view to allow the customer to sort their order history by IP Address, which is a custom order field. We can both display the custom order field data and make the column sortable.
Here is code to add the custom field sortable column:
SortBy Parameter will always be in the following format for sorting by custom fields:
Ascending
SortBy=customfield:<module_code>:<custom_field_code>
Descending
SortBy=customfield_desc:<module_code>:<custom_field_code>
Note: Most of the time the module code will be “customfields”. However, there are other modules which implement the custom field API. For example, if you wanted to show a custom field from the Order Workflows module the syntax would look like this:
customfield:orderworkflow:successfully_retrieved_orders