Commerce Commerce 1.x Upgrades v1.2

Most upgrades are automatically applied, but sometimes you may need to update custom templates, or configuration, to take advantage of new features or improvements. Those changes are discussed here.

Commerce v1.2 is mostly a maintenance release.

Template: no payment methods available

The default template in frontend/checkout/payment-method.twig now has an “else” condition in the foreach loop, to show a message if no payment method is available for a current order.

To add this to a custom template, replace the {% endfor %} around line 41 with the following:

{% else %}
    <div class="c-cart-error">
        {{ lex('commerce.checkout_payment_nomethodsavailable') }}
    </div>
{% endfor %}

The lexicon may not yet be fully translated.

FYI: changes to sent messages

Previously, when sending an order message, the content saved in the database would keep the Twig syntax (e.g. {% extend "some/email/template.twig" %}), which would be re-evaluated each time you view the order message in the dashboard. While that’s useful for testing changes to templates, it means that the message as shown is not necessarily the same as what was actually sent.

As of v1.2, the default behavior is to write the fully parsed content of an email message to the database instead when it is sent. This means you can rely on that matching what was actually sent.

To revert back to the pre-v1.2 behavior of keeping the twig syntax and rendering on each view, disable the commerce.save_sent_message_content system setting before a message is sent. We do recommend turning that back on when you’re done with testing.

Context-related improvements

While the dashboard would already use context settings for order-related actions, such as running an email status change, v1.2 also:

  • dynamically switches the language (lexicons) to the cultureKey of the context
  • support settings in ClientConfig’s multi-context mode

Adding customers’ email and phone to the default emails (v1.2.2)

The following default templates have been updated to include the customers’ email and phone number when rendering the address:

  • emails/message.twig around line 322 and 328
  • emails/order-received.twig around line 325 and 332
  • emails/order-to-merchant.twig around line 48 and 54

To add these changes to your own templates, add the following two blocks around the mentioned lines in each file:

{% if shipping_address.email %}{{ shipping_address.email }}{% endif %}
{% if shipping_address.phone %}<br>{{ shipping_address.phone }}{% endif %}
{% if billing_address.email %}{{ billing_address.email }}{% endif %}
{% if billing_address.phone %}<br>{{ billing_address.phone }}{% endif %}