Skip to content

When an order is completed (placed)

Sends a notification when a Commerce Order has been completed. Fires when the order transitions from cart status.

Use this event for customer receipts ("Thanks for your order") and internal alerts ("A new order has been placed").

Requires Craft Commerce

Only available when the Craft Commerce plugin is installed.

Field Conditions

Field conditions restrict the notification based on the element's content, using Craft's native conditions framework. Build a rule set against the element's attributes and field values, and the notification will be sent only when every rule matches.

Must match all conditions

The condition builder evaluates every rule with AND semantics, so each rule must pass for the notification to be sent.

The "has changed" operator

Field rules now include an additional "has changed" operator, alongside the existing standard options.

When the element is saved, the "has changed" operator checks whether the field's value has changed during the save, (regardless of what the new value is). The notification will only be sent when the specified field's value has changed.

Twig variables

The object variable (and its order alias) is the completed Order.

twig
Order {{ order.shortNumber }} was placed by {{ order.email }}.
Total: {{ order.totalPrice|currency }}

Notifying the customer

To notify the customer of an Order, use Dynamic Recipients and pass the order's email address into {% setRecipients %}:

twig
{% if order.email %}
    {% setRecipients order.email %}
{% endif %}

If the customer is a Craft user, you can instead pass the User object to get more data from the recipient variable:

twig
{% if order.customer %}
    {% setRecipients order.customer %}
{% endif %}

Examples

Thank you message and receipt for the customer

twig
Thanks for your order, {{ order.billingAddress.firstName }}!

Order {{ order.shortNumber }} - {{ order.totalPrice|currency }}

We'll send tracking info as soon as your items ship.

Internal alert with order summary

twig
New order: {{ order.shortNumber }}

Customer: {{ order.email }}
Total: {{ order.totalPrice|currency }}
Items: {{ order.totalQty }}

SMS to fulfillment for high-value orders

twig
{% if order.totalPrice < 500 %}
    {% skipMessage "Order under $500." %}
{% endif %}

Priority order: {{ order.shortNumber }}
Total: {{ order.totalPrice|currency }}
Ship today.