How To Build Export Templates: Filters and Custom Fields
IN THIS GUIDE
Overview
Filters: Search & Replace | Date Format | Skip Line
Special Fields
Using Twig
Overview
With export templates, you can export any orders or other order data from Order Desk in a file you can customize. For an overview of how to set up and work with export templates, read through the Building Export Templates guide.
In this guide, we will cover field filters and other custom fields that can be used or added to your export templates.
Field filters give you a little more control over what does (or doesn't) get included with your exported files. These filters let you make some changes to your export template, such as replacing, formatting and/or skipping certain data.
Custom fields, separate from field filters, are special fields you can add to your template that may require special formatting that will be covered at the end of this guide.
Filters
To access the field filters in your export template, look at the lower right corner of the template page, underneath the list of Available Fields.
Click the Add Filter button to set up your first filter.
You can add as many separate filters as needed.
Filters are case sensitive and do not have curly brackets around them. Values need to match your orders exactly.
Search & Replace
Use the Search & Replace filter to change specific data from your orders when exported into a file. You can change a SKU, an address, a shipping method, or any other field name available.
EQUALS Special Setting
If one of the values you need to search for or replace has an = sign in it already, use _EQUALS_ in the filter instead to avoid problems.
For example, if you need to replace the code 12=34 with 1234, instead of setting the filter to 12=34=1234, set it to 12_EQUALS_34=1234.
Replace SKU Example
If you need to replace a SKU, set the field name "code" in the field name to target box.
Add your SKU followed by = and the SKU to replace it in the file, one per line:
This can be used to completely change a SKU or to reformat a SKU such as adding or removing extra spaces.
The SKU in your order in Order Desk will not change, but the SKU in the exported file will reflect the filter.
Replace Shipping Method Example
Search & Replace lets you change any field in the order that can be exported. For instance, if the shipping method on the order is Standard:
But in the exported file, you may need that to be a specific carrier and method. If so, you can change this with the Search & Replace filter targeting shipping_method:
Date Format
The date format filter is to change the way dates are displayed in your exported file. The default format in Order Desk (Y-m-d H:i:s) can be changed in your store settings or with this filter for exported files only.
For instance, change the order date targeting date_added, using this PHP reference for options:
Skip Line
The skip line filter is for removing lines from the file that would otherwise be exported based on the fields in the template.
Exclude specific lines from a field that you otherwise want in the file. As an example, if you want to export all of your closed orders but leave out a specific SKU, target the code field and enter the SKU you want left out of the file:
This can be used for any field name in your template as long as you have a specific value that you want to skip. Another example is to export all orders except any with a specific shipping country, such as France:
Or even a specific type of item based on the product name, for instance, skip all products named Mug:
You can even export all of your orders from Order Desk, but skip any that are in a specific folder. Make sure the folder is one of the fields in the template, then target that field, folder_name, and add the name of the folder you want left out of the file, for instance "Canceled":
Special Fields
Custom Fields
If you have any specific fields that will always be the same for every order in your file, such as your vendor ID, business name, or any other field value that won't change on an order by order basis, you can type this directly into the field in your template.
Unlike Order Desk field names, with curly brackets around them, that pull specific information from each order to use in the exported file, these will be exported exactly as you write them in the template:
This can also be used in combination with Order Desk field names in the template. For instance, if you need to add a prefix to your SKUs in the file, you can type this ahead of the field name in the template.
Order Confirmation URL
You can add the order confirmation URL to your file if sending the file to a vendor or fulfillment service that won't be sending a file back with shipments.
The recipient can use this URL to add a shipment back to each order directly without needing to send a file back or have access to your Order Desk account. This is the same URL that is used in the dropship email template.
Current Store Datetime
You can export your store's current datetime, applied to each row in the file when the template is exported, by using the field {current_store_datetime}. The format will use the default Y-m-d H:i:s.
Using Twig
Add ORDER-LOOKUP to the custom parameters of the template so you can use Twig to add extra or customized information to an export that isn't otherwise available.
As an example, set {{ order_shipments.0.carrier_code }}
in the export template to export the Carrier Code from the shipment.
See this for more information on Twig.