Available Variables

The following twig template variables are available:

craft.commerce.settings #

To get all Craft Commerce general settings:

{% set settings = craft.commerce.settings %}

craft.commerce.products #

See craft.commerce.products

craft.commerce.orders #

See craft.commerce.orders

craft.commerce.cart #

See craft.commerce.cart

craft.commerce.countriesList #

Returns a list usable for a dropdown select box.

Data returned as [32:'Australia', 72:'USA']

<select>
{% for id, countryName in craft.commerce.countriesList %}
    <option value="{{ id }}">{{ countryName }}</option>
{% endfor %}
</select>

craft.commerce.countries #

Returns an array of Country Models.

<select>
{% for country in craft.commerce.countries %}
    <option value="{{ country.id }}">{{ country.name }}</option>
{% endfor %}
</select>

craft.commerce.statesArray #

Returns an array indexed by country IDs, usable for a dropdown select box.

Data returned as [72:[3:'California', 4:'Washington'],32:[7:'New South Wales']]

<select>
{% for countryId, states in craft.commerce.statesArray %}
    <optgroup label="{{ craft.commerce.countriesList[countryId] }}">
    {% for stateId, stateName in craft.commerce.statesArray[countryId] %}
        <option value="{{ stateId }}">{{ stateName }}</option>
    {% endfor %}
  </optgroup>
{% endfor %}
</select>

craft.commerce.states #

Returns an array of State Models.

<select>
{% for states in craft.commerce.countries %}
    <option value="{{ state.id }}">{{ state.name }}</option>
{% endfor %}
</select>

craft.commerce.availableShippingMethods #

Returns the shipping methods available to applied to the current cart. Will not include some shipping methods if none of the shipping method’s rules can match the cart.

{% for handle, method in craft.commerce.availableShippingMethods %}
    <label>
        <input type="radio" name="shippingMethod" value="{{ handle }}"
               {% if handle == cart.shippingMethodHandle %}checked{% endif %} />
        <strong>{{ method.name }}</strong> {{ method.amount|currency(cart.currency) }}
    </label>
{% endfor %}

craft.commerce.paymentMethods #

Returns all payment methods available to the customer.

{% if not craft.commerce.paymentMethods|length %}
    <p>No payment methods available.</p>
{% endif %}

{% if craft.commerce.paymentMethods|length %}
<form method="POST" id="paymentMethod" class="form-inline">

    <input type="hidden" name="action" value="commerce/cart/updateCart">
    <input type="hidden" name="redirect" value="commerce/checkout/payment">
    {{ getCsrfInput() }}

    <label for="">Payment Method</label>
    <select id="paymentMethodId" name="paymentMethodId" class="form-control" >
        {% for id,name in craft.commerce.paymentMethods %}
            <option value="{{ id }}" {% if id == cart.paymentMethod.id %}selected{% endif %}>{{ name }}</option>
        {% endfor %}
    </select>

</form>
{% endif %}

craft.commerce.orderStatuses #

Returns an array of all custom order statuses (Order Status Model) set up in the system.

{% set statuses = craft.commerce.orderStatuses %}

craft.commerce.taxCategories #

Returns an array of all tax categories set up in the system.

{% for taxCategory in craft.commerce.taxCategories %}
{{ taxCategory.id }} - {{ taxCategory.name }}
{% endfor %}

See Order Status Model

craft.commerce.productTypes #

Returns an array of all product types set up in the system.

{% for type in craft.commerce.productTypes %}
{{ type.handle }} - {{ type.name }}
{% endfor %}

craft.commerce.orderStatuses #

Returns an array of all order statuses (Order Status Model) set up in the system.

{% for status in craft.commerce.orderStatuses %}
{{ status.handle }} - {{ status.name }}
{% endfor %}

craft.commerce.discounts #

Returns an array of all discounts set up in the system.

{% for discount in craft.commerce.discounts %}
{{ discount.name }} - {{ discount.description }}
{% endfor %}

craft.commerce.getDiscountByCode(code) #

Returns a discount that matches the code supplied.

{% set discount = craft.commerce.getDiscountByCode('HALFOFF')
 %}
{% if discount %}
{{ discount.name }} - {{ discount.description }}
{% endif %}

craft.commerce.sales #

Returns an array of all sales set up in the system.

{% for sale in craft.commerce.sales %}
{{ sale.name }} - {{ sale.description }}
{% endfor %}

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!