This article discusses how to setup order filters for marketplaces and carts. Note that this is an advanced feature; it's recommended that you first familiarize yourself with the order mappings section of the connector (in FarApp Menu navigate to [storefront/cart and account] > Mappings > Orders), as many concepts are re-used from our order mapping interface.
The order filter editor can be found by selecting the connector and account in the FarApp menu on the left. Then navigate to Settings > Orders and click Advanced Options on the page. If the particular marketplace/cart you're viewing supports order filtering, you will see two buttons at bottom of the screen: Edit Order Filters and Test Order Filters. Click Edit Order Filters to open the the editing interface.
Order filters are set up as follows. First, you check whether a condition of your choosing is met by an order. You can then decide what to do if that condition is true, and alternatively, what to do if it's false. This can involve checking additional conditions, or simply setting the order to be filtered/not filtered.
There are a couple terms to familiarize yourself with before starting to set up a filter:
- Order Header Value: Values that give general information about an order, such as billing and shipping information, order totals, the order date, etc. The interface provides a list of such values.
- Fixed Value: A constant value (something that does not change from order to order, such as the number '1'.
With these two terms in mind, we can look at an example filter. Suppose, for whatever reason, you wanted to filter out any orders where the shipping zip code is 90210. In this case, we want to check if the Order Header Value 'Shipping Zip' equals the Fixed Value '90210'. If this condition is true, we want to filter the order out. Otherwise, we want to import the order.
You'll notice the interface follows this same logic. Let's try setting up this example filter. If you haven't set up a filter before, the first row starts with 'Check if' Fixed Value (Blank) Equals Fixed Value (Blank). We want to check if an Order Header Value equals a Fixed Value, so let's change the first dropdown to 'Order Header Value'. When you do so, the second text box becomes a dropdown with all the valid Order Header Values you can select. Towards the bottom of this list, you should see 'Shipping Zip'; select this value.
The third text box contains the operation you want to use; it's already set to 'Equals' by default, so no need to change this.
The fourth box is set to Fixed Value; we want to check if the Shipping Zip equals the Fixed Value '90210', so this is correct.
Lastly, we need to enter 90210 into the last text box. With this in place, we're now checking the condition we discussed (If the Shipping Zip Equals 90005).
The next row lets us set the behavior if the condition is true. We decided earlier that in this case, we should filter the order out. You'll notice the first text box is set to the 'Set Order Filter' option; this is what we want. In the second dropdown in this row, you'll see two options 'Don't Import Order' and 'Import Order'. Selecting the first option will prevent FarApp from importing the order if the condition is true.
Finally, the last row lets you set the behavior if the condition is not true. Again, we want 'Set Order Filter' in the first dropdown. We decided that we should import any order that don't have the shipping zip 90210, so we should set the second dropdown to 'Import Order'.
With all this in place, you could hit Save Changes, and FarApp would then start filtering out orders with the shipping zip code 90210. You shouldn't save this filter unless you actually want to use it, however.
You can use the concepts we've discussed here to setup a variety of simple filters. Under the dropdown that says Equals, you'll see a variety of other operations you can use to check conditions. For instance, suppose you want to filter out any orders where the shipping zip code starts with '9'. You could simply change the value 'Equals' to 'Starts With' and value '90210' to '9'. If you don't know how an operation works, try selecting it and then hovering over it with your mouse; some operations have tooltips which help explain them.
Test Your Filters
Once you've setup a filter that you want to use, click Save Changes and close the interface. You'll see another button: Test Order Filters. Click this, and you'll see a pop-up with a text box, prompting you to enter an order ID. Enter the ID of an order from the storefront and account you're currently editing, and click Check Order.
The interface will then show a result indicating whether FarApp would or would not import that order according to the filters you've set up. You can use this functionality to ensure the correct orders are included and excluded by FarApp.
Under the dropdowns which include Order Header Value and Fixed Value, you'll see another option: Computed Value. This option lets you setup much more complex logic. For instance, maybe you want the second value you're checking in your condition to vary based on a second condition. This feature would allow you to set that up.
Try selecting Computed Value for the second value; the next text box will change to a link. Clicking that link will take you an interface that looks exactly like the one you've just been working on, except with blank values. Here, you can check another condition, and set the resulting value if the condition is true or false. Whatever the result of this check, the result will become the second value in your original condition. You can click 'Go Back' to return to your initial condition.
You'll notice that there's also a new dropdown when you click on the Computed Value link, currently set to 'Set Value Conditionally.' If you click this dropdown, there's another option Calculate Value. If you select this option, the condition checking interface will be replaced with another interface that lets you modify and calculate new values, using operations such as addition and multiplication, as well as text editing (like converting a value to upper case).
Let's look an example. Make sure you're viewing the top-level condition of your filter (not a Computed Value). Suppose you want to filter out any orders where the Shipping Total plus the Tax Total is greater than $50.00. In this case, we're checking if a Computed Value (Shipping Total + Tax Total) is less than a Fixed Value (50). Set the first dropdown to Computed Value and click the link created.
Now, in this case, we don't want to check another condition, we just want to calculate a new value. So change the 'Set Value Conditionally' dropdown to 'Calculate Value.' We know we want to set the first value to the Order Header Value 'Shipping Total', so change the first dropdown to Order Header Value and the second dropdown to Shippng Total. Next, you'll notice the operation defaults to 'Converted to Lower Case'. Change this to 'Added To', and a second set of text boxes will appear. Set these to Order Header Value and Tax Total, respectively.
With this in place, we are now successfully calculating the first value in our condition as Shipping Total plus Tax Total. Click Go Back to return to your condition. Now, you can set the operation to 'Is Less Than', and the second value to the Fixed Value '50'.
Finally, set the output to Don't Import Order if the condition is true, and Import Order if it's false, and the example mapping is complete.