Create a Custom Order Advanced Filter
Learn how to add a custom advanced filter to the order list in Umbraco Commerce.
The order list in the Commerce section includes advanced filters, such as Order Number, First Name, and Placed On or After. You can add your own filters to search orders by other criteria.
This guide shows how to create a filter that lists orders by payment method. Combined with the built-in date filters, it can show, for example, how many orders a store completed with a given payment method each week.
Create the filter
An advanced filter is a class that inherits from OrderAdvancedFilterBase, decorated with the AdvancedFilter attribute.
Create a new class, for example
OrderPaymentMethodAdvancedFilter.cs.Add the following code:
using Umbraco.Commerce.Cms.Filters;
using Umbraco.Commerce.Common.Specifications;
using Umbraco.Commerce.Core.Models;
using Umbraco.Commerce.Core.Specifications.Order;
using Umbraco.Commerce.Extensions;
namespace MyProject.Filters;
[AdvancedFilter("paymentMethod",
Group = "order",
Label = "Payment method ID",
Description = "Orders that use the given payment method",
EditorUiAlias = "Umb.PropertyEditorUi.TextBox")]
public class OrderPaymentMethodAdvancedFilter : OrderAdvancedFilterBase
{
public override bool CanApply(string value)
=> Guid.TryParse(value, out _);
public override IQuerySpecification<OrderReadOnly> Apply(
IQuerySpecification<OrderReadOnly> query,
IOrderQuerySpecificationFactory where,
string value)
=> query.And(where.HasPaymentMethod(Guid.Parse(value)));
}The filter has three parts:
The
AdvancedFilterattribute sets the filter's alias and how it appears in the backoffice:Groupplaces the filter in the Order group. The built-in groups areorder,customer, andorderLine.LabelandDescriptionare shown next to the filter.EditorUiAliassets the property editor used to enter the value. This example uses a text box.
CanApplychecks whether the entered value is valid. The filter is only applied when it returnstrue.Applyadds the filter condition to the order query.HasPaymentMethodis one of the conditions available onIOrderQuerySpecificationFactory.
Register the filter
Register the filter with a composer so Umbraco Commerce adds it to the order list.
Create a new class, for example
OrderFiltersComposer.cs.Add the following code:
Build and restart the site.
Use the filter
The filter needs the ID of the payment method to filter on.
Go to the Settings section.
Expand your store under Stores and select Payment Methods.
Select the payment method.
Copy the Id from the Info panel.

To filter the order list:
Go to the Commerce section.
Expand your store and select Orders.
Select the filter icon next to Payment Status.
Enter the ID in Payment method ID.

Select Apply.
The order list shows only the orders that use the given payment method.

To count the orders for a specific week, also set Placed On or After and Placed On or Before in the Advanced Filters panel.
Last updated
Was this helpful?