<p>Checkboxes fields (and other multi-select fieldtypes) return a <a href="https://craftcms.com/classreference/fieldtypes/MultiOptionsFieldData" rel="nofollow">MultiOptionsFieldData</a> instance, not an array.</p>

<p>This should work:</p>

<pre><code>{% if currentUser.userField.contains(purchaseable.myCustomField) %}
</code></pre>

CC BY-SA 3.0
2016-01-02T02:02:58.660Z
Worked perfectly. You are spot-on, I was approaching it as an array. Thank you!
Damon
CC BY-SA 3.0
2016-01-01T22:30:14.927Z
2016-01-01T22:30:14.927Z
Mats Mikkel Rummelhoff
<p>I have a product variant that a user can choose from. It looks like this:</p>

<pre><code>&lt;select name="purchasableId" class="form-control"&gt;
    {% for purchasable in product.variants %}
        &lt;option {% if purchasable.stock &lt;= 0 and purchasable.unlimitedStock == false %}disabled {% endif %} value="{{ purchasable.purchasableId }}"
            {% if currentUser is defined and purchasable.myCustomField in currentUser.userField %}selected{% endif %}&gt;{{ purchasable.myCustomField.label }} &amp;ndash; {{ purchasable.price|currency(cart.currency) }}&lt;/option&gt;
   {% endfor %}
&lt;/select&gt;
</code></pre>

<p>Where I'm stuck is this:</p>

<pre><code>purchasable.myCustomField
</code></pre>

<p>Should (and does) equal this:</p>

<pre><code>{{ currentUser.userField }}
</code></pre>

<p>I know it's a syntax problem... just not sure where I'm off.</p>

<p><strong>EDIT</strong></p>

<p>To test, this is what the data looks like:</p>

<pre><code>purchasable.myCustomField  // this is a drop down value is "blue"
currentUser.userField      // this is a checkbox that has the value "blue" in it
</code></pre>

CC BY-SA 3.0
2016-01-01T21:08:54.833Z
What FieldTypes are `purchasable.myCustomField` and `currentUser.userField`?
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2016-01-01T21:10:59.473Z
`purchasable.myCustomField` is a drop-down & `currentUser.userField` is a checkbox group. So I am trying to see if `purchasable.myCustomField` is in `currentUser.userField`
Damon
<user-profile><plugin-craftcommerce>
How can I pre-select a product variant based on user profile?
# How can I pre-select a product variant based on user profile?

(Asked by: username_0 on 2016-01-01)

I have a product variant that a user can choose from. It looks like this:

    {% for purchasable in product.variants %}
        {{ purchasable.myCustomField.label }} – {{ purchasable.price|currency(cart.currency) }}
   {% endfor %}


Where I'm stuck is this:
purchasable.myCustomField

Should (and does) equal this:
{{ currentUser.userField }}

I know it's a syntax problem... just not sure where I'm off.
EDIT
To test, this is what the data looks like:
purchasable.myCustomField  // this is a drop down value is "blue"
currentUser.userField      // this is a checkbox that has the value "blue" in it

**Tags:** user-profile, plugin-craftcommerce

> **Comments:**
> **username_1**: What FieldTypes are `purchasable.myCustomField` and `currentUser.userField`?  
> **username_0**: `purchasable.myCustomField` is a drop-down & `currentUser.userField` is a checkbox group. So I am trying to see if `purchasable.myCustomField` is in `currentUser.userField`  

---

## 1 answers

### Answer by username_1 on 2016-01-01. Score: 1 | Accepted answer

Checkboxes fields (and other multi-select fieldtypes) return a MultiOptionsFieldData instance, not an array.
This should work:
{% if currentUser.userField.contains(purchaseable.myCustomField) %}

> **Comments:**
> **username_0**: Worked perfectly. You are spot-on, I was approaching it as an array. Thank you!  

---

