Customizing The WP Inventory Manager Filter Options

The WP Inventory Manager filter can be extended to meet your exact needs

This filter is used to display the items that are available to “sort by” in the filter drop down of the inventory pages:

wpim_filter_sort_by_options()

However, you may find that simply turning off labels that you do not want to use in the dashboard does not get rid of all of them.  An example being the “date added”.  For these fields, you need to unset them using a bit of code in your functions.php.

So for example:

add_filter('wpim_filter_sort_by_options', 'custom_sort_options');

function custom_sort_options( $fields ) {
    // list the fields in the order desired.  Be sure the field name is accurate!

    $my_fields = array(
        // name of field     => Displayed Label
        'inventory_name'   => 'Product',
        'inventory_make'   => 'Output Voltage(s)',
        'inventory_serial'   => 'Wattage',
        'inventory_size'   => 'Dimension',
        'inventory_manufacturer' => 'Industry'
        // ... etc
    );

    // Change to FALSE or remove it completely if you ONLY want to include the fields listed above
    $include_all_fields = FALSE;

    if ( ! empty($include_all_fields)) {
        foreach ( $my_fields AS $key => $field ) {
            unset( $fields[ $key ] );
        }

        $my_fields = array_merge( $my_fields, $fields );
    }

    return $my_fields;
}

Would only render the filter options:

  • inventory_name
  • inventory_make
  • inventory_serial
  • inventory_size
  • inventory_manufacturer

Here is a complete list of all the sort order, available keys:

inventory_date_added
inventory_date_updated
inventory_description
category_id
inventory_fob
inventory_image
inventory_images
inventory_manufacturer
inventory_media
inventory_name
inventory_number
inventory_price
inventory_quantity
inventory_quantity_reserved
inventory_serial
inventory_size
inventory_slug
inventory_sort_order
inventory_status
user_id
inventory_year
inventory_make
inventory_model