craft.commerce.orders

How to get orders #

You can access your site’s orders from your templates via craft.commerce.orders It returns an ElementCriteriaModel object.

{% set orders = craft.commerce.orders.find() %}

{% for order in orders %}
    {{ order.number }} - {{ order.totalPrice}} <br>
{% endfor %}

Parameters #

craft.commerce.orders supports the following parameters:

type #

Product Type model or handle.

typeId #

Product type id.

number #

The unique hash of the order.

completed #

Accepts true or false. e.g {% set orders = craft.commerce.orders.completed(true).find() %} would return completed orders since they have isCompleted set to true.

dateOrdered #

The date the order was completed.

orderStatus #

accepts an orderStatus model.

orderStatusId #

Accepts the id of an Order Status.

customer #

A customer Model can be passed to get orders for that customer only. e.g {% set orders = craft.commerce.orders.customer(craft.commerce.customer).find() %} Do not use this to get a cart, as the default response does not include orders that are still carts (use {% set cart = craft.commerce.getCart %} to get the current user’s cart).

user #

A customer Model can be passed to get orders for that user only. e.g {% set orders = craft.commerce.orders.user(currentUser).find() %} Do not use this to get a cart, as the default response does not include orders that are still carts (use {% set cart = craft.commerce.getCart %} to get the current user’s cart).

customerId #

Accepts an id of a customer.

updatedAfter #

Only fetch orders with an Updated Date that is on or after the given date.

You can specify dates in the following formats:

  • YYYY
  • YYYY-MM
  • YYYY-MM-DD
  • YYYY-MM-DD HH:MM
  • YYYY-MM-DD HH:MM:SS
  • A Unix timestamp
  • A DateTime variable

updatedBefore #

Only fetch orders with an Updated Date that is before the given date.

You can specify dates in the following formats:

  • YYYY
  • YYYY-MM
  • YYYY-MM-DD
  • YYYY-MM-DD HH:MM
  • YYYY-MM-DD HH:MM:SS
  • A Unix timestamp
  • A DateTime variable

isPaid #

Accepts true or false. Limits results to only orders where totalPaid is >= totalPrice

isUnPaid #

Accepts true or false. Limits results to only orders where totalPaid is < totalPrice

hasPurchasables #

Returns orders that contains specific purchasables.

Accepts: An array of models meeting the Purchasable interface (like variants) OR an array of Purchasable Element IDs

For example:

{% if currentUser %}
    {% set order = craft.commerce.orders.user(currentUser).hasPurchasables([product.defaultVariant]).first() %}
    {% if order %}
        I already own this product:  <a href="shop/order?orderNumber={{ order.number }}">Order #{{ order.shortNumber }}</a>
    {% endif %}
{% endif %}

or

{% set  orders = craft.commerce.orders({
  hasPurchasables: [32,34,35]
}) %}

Buy Craft Commerce

Craft Commerce site license

Includes

  • Standard tech support
  • Unlimited app updates
  • Craft Pro site license
Buy now for $999
Can I try before buying?

Absolutely. Just download it from the “Download” button in the site header and follow our installation instructions. You’ll have the full feature set to experiment with, with just one limitation: you won’t be able to charge credit cards. Until Craft Commerce has been purchased and activated, it’s limited to a single dummy gateway.

Will there be recurring/upgrade fees?

Nope, it’s just a one-time license fee per site.

Can I use this on an existing Craft site?

Yes! And if you already have a Craft Pro license (or you don’t need one), just flip that “Include a Craft Pro license” switch in the purchase form, and we’ll drop the price to $700.

Is Craft Pro required?

Craft Commerce does not require Craft Pro; it works perfectly fine on Craft Client and Personal editions as well!

Can I try before buying?

Absolutely. Just download it from the “Download” button in the site header and follow our installation instructions. You’ll have the full feature set to experiment with, with just one limitation: you won’t be able to charge credit cards. Until Craft Commerce has been purchased and activated, it’s limited to a single dummy gateway.

Will there be recurring/upgrade fees?

Nope, it’s just a one-time license fee per site.

Can I use this on an existing Craft site?

Yes! And if you already have a Craft Pro license (or you don’t need one), just flip that “Include a Craft Pro license” switch in the purchase form, and we’ll drop the price to $700.

Is Craft Pro required?

Craft Commerce does not require Craft Pro; it works perfectly fine on Craft Client and Personal editions as well!