<p>Commerce 1:</p>

<pre><code>{% set paymentMethod = null %}
{% for pm in craft.commerce.paymentMethods %}
    {% if pm.id == 2 %}{% set paymentMethod = pm %}{% endif %}
{% endfor %}

{{ paymentMethod.name }}
</code></pre>

<p>Commerce 2:</p>

<p><code>{{ craft.commerce.gateways.getGatewayById(2).name }}</code></p>

CC BY-SA 4.0
2018-08-29T06:54:06.857Z
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
CC BY-SA 4.0
2018-08-30T00:40:24.677Z
Unfortunately not
Luke Holder
CC BY-SA 4.0
2018-08-29T01:58:18.827Z
2018-08-29T01:58:18.827Z
Luke Holder
<p>In Craft 2, is it possible to query a specific element by ID in Twig?  They aren't mentioned in the docs.</p>

<p>I was trying things like these but without success:</p>

<pre><code>{{ craft.commerce.paymentMethods.id(1).name }}
</code></pre>

<templating><plugin-craftcommerce><query><payment-methods><discounts>
Payment Method and Discount elements query by ID in Twig
# Payment Method and Discount elements query by ID in Twig

(Asked by: username_0 on 2018-08-29)

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:
{{ craft.commerce.paymentMethods.id(1).name }}

**Tags:** templating, plugin-craftcommerce, query, payment-methods, discounts


---

## 1 answers

### Answer by username_1 on 2018-08-29. Score: 2 | Accepted answer

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

{{ paymentMethod.name }}

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

> **Comments:**
> **username_0**: 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?  
> **username_1**: Unfortunately not  

---

