In Craft 2, is it possible to query a specific element by ID in Twig? They aren't mentioned in the docs.

I was trying things like these but without success:

{{ }}
up vote 2 down vote accepted

Commerce 1:

{% set paymentMethod = null %}
{% for pm in craft.commerce.paymentMethods %}
    {% if == 2 %}{% set paymentMethod = pm %}{% endif %}
{% endfor %}

{{ }}

Commerce 2:

{{ craft.commerce.gateways.getGatewayById(2).name }}

  • For Commerce 1, it only seems to work for payment methods that are available for checkout. Is there a way to query methods that are not available for checkout? – biko Aug 29 at 6:54
  • Unfortunately not – Luke Holder Aug 30 at 0:40

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.