{function name=select n='' o=[] d='' with_empty=true c=""} {/function} {capture assign="buttons"}
{/capture} {capture assign="fields"}
{$hash_app_show_contacts = ifset($hash, 'app', 'show_contacts', 'val', 'customers')}
{strip} {if isset($hash.app.orders_total_sum)} {$_default = 'all'} {else} {$_default = 'paid'} {/if} {$hash_app_consider_orders = ifset($hash, 'app', 'consider_orders', 'val', $_default)} {/strip}
[`Number of orders`]
{select n="app.number_of_orders.op" o=['>=', '=', '<='] d=$hash.app.number_of_orders.op|default:'' with_empty=false}
[`Total spent`]
{if isset($hash.app.orders_total_sum)} [`from`] [`to`] {else} [`from`] [`to`] {/if} {$primary_currency}
[`Last order`]
{capture "_last_order_options"} {/capture} {sprintf('[`Over %s ago`]', $smarty.capture._last_order_options)}
[`First order`]
{select n='app.first_order_datetime.op' o=[['id' => '<=', 'name' => _w('or earlier')], ['id' => '>=', 'name' => _w('or later')]] c="non-wa-contact-field" d=$hash.app.first_order_datetime.op|default:'' with_empty=false}
{if $payment_methods}
[`Payment`]
{select n='app.payment_method' o=$payment_methods d=$hash.app.payment_method.val|default:'' c="non-wa-contact-field"}
{/if} {if $shipping_methods}
[`Shipping`]
{select n='app.shipment_method' o=$shipping_methods d=$hash.app.shipment_method.val|default:'' c="non-wa-contact-field"}
{/if} {if $coupons}
[`Applied discount coupon`]
{select n="app.coupon" o=$coupons d=$hash.app.coupon.val|default:'' c="non-wa-contact-field"}
{/if}
[`Purchases`]
[`Purchased product`]
[`Purchase time frame`]
[`Customer info`]
[`Referer`]
{select n="app.referer" o=$referers d=$hash.app.referer.val|default:'' c="non-wa-contact-field"}
[`Storefront`]
{select n="app.storefront" o=$storefronts d=$storefront c="non-wa-contact-field"}
{if $utm_campagns}
[`UTM campaign`]
{select n="app.utm_campaign" o=$utm_campagns d=$hash.app.utm_campaign.val|default:'' c="non-wa-contact-field"}
{/if}
[`Address`]

{foreach $address_fields as $field} {$field.name|escape} {if $field.field_class === 'waContactBranchField'} [`clear`] {/if} {$field.html} {/foreach}

{/capture} {$container_id = $wa->param('container_id', 's-customers-search-form')} {if !$wa->param('just_fields')}

[`New search`]

{$fields} {$buttons}
{else}
{$fields}
{/if}