Filter Reference

action


This filter allows you to call a function which executes a pre-defined action. When an action filter is used in a form, then the contents of that form are submitted along with the action.


If you choose to use an action outside of a context of a form then you can optionally pass in specific parameters into the action.


Sample usage:

<form class="modal-content" 
        action="{{ 'cancel_subscription' | action }}"  
        name="og_subscription_cancel"
        @submit={{ 'ev => $(ev.target).closest(".modal").modal("hide")' | js}}
        @reset={{ 'ev => $(ev.target).closest(".modal").modal("hide")' | js}}>

In the example above, when a user submits the form, the cancel_subscription action will fire. The @submit and @reset are triggered after the user successfully submits the form or resets it back to default form values. You can read more about the js filter below.

action namedescription
cancel_subscriptionThis action will cancel a subscription. The action should be used as part of a form which contains a list of cancellation reasons that customers can choose from.
change_shipment_dateThis action will change the next upcoming order date for a given order. The action should be used as part of a form which contains the order id and the new date.
change_shipping_addressThis action will allow a customer to change a shipping address tied to a specific subscription or all subscriptions. The action should be used as part of a form which contains the subscription id and all address fields which are required for a new address to be created in our system.
send_nowThis action will allow a customer to send their next upcoming order as soon as possible as opposed to the original scheduled date. This action takes in a Order object.

Actions are very powerful but also require very specific usage. The best example of their usage can be found in the current set of default templates which you can find under the ACTIONS heading in the Templates page.



Additional examples of usage are also included below:

<button click={{'send_now' | action(order)}}>
{{ 'modal_send_now_save' | t }}
</button>
<form action="{{ 'reactivate_subscription' | action }}"  
...
>

currency


Whenever you are displaying a price, you can use this filter to ensure that the number is properly formatted and displayed as a currency which the customer is accustomed to. The actual display configuration for a currency is based on the currency_code and currency_display keys in your locale files. By default the en-us locale will render as $ X.XX.



Sample usage:

{% if order_item.show_original_price %}
  <span>{{ order_item.price | currency }}</span>
{% endif %}
<span>{{ order_item.total_price | currency }}</span>

date


The date filter, allows you display a date in a specific format. The filter takes in an optional parameter which allows you to override the default format. We are utilizing a popular date library called daysjs so all formats which are supported can be found here. Below are some of the more popular choices which you should consider using in your templates:

formatdescription
YYTwo-digit year
YYYYFour-digit year
MThe month, beginning at 1
MMThe month, 2-digits
MMMThe abbreviated month name
MMMMThe full month name
DThe day of the month
DDThe day of the month, 2-digits
dThe day of the week, with Sunday as 0
ddThe min name of the day of the week
dddThe short name of the day of the week
ddddThe name of the day of the week
LEnglish: MM/DD/YYYY
LLEnglish: MMMM D, YYYY
lEnglish: M/D/YYYY
llEnglish: MMM D, YYYY
{# Render the order placement date using the default LL date format #}
{{ order.place | date }}

find


The find filter allows you to find a specific object within a list of objects based on either the reference of an object or the object's id. You can find some sample usage below:

{# Find a subscription based on item subscription id #}
{% set subscription = subscriptions | find(order_item.subscription) %}

{# Find an item based on a specific subscription id #}
{% set subscription = subscriptions | find('sub123abc') %}

first


The first filter will return the first element of an array.

{% set subscription = subscriptions | first %}

Future iteration

🚧

Future Iteration

Filters below this call out are available but we are still working through the interface. Full documentation will be available shortly.

get


if_defined


js


last


reject


select


shuffle


sort


t