Body: <p>I am populating a drop-down with product variants like this:</p>
  
  <pre><code>&lt;select name="mySelect" class="form-control"&gt;
  &lt;option value=""&gt;Select&lt;/option&gt;
  {% for purchasable in product.variants %}
      &lt;option {% if purchasable.stock &lt;= 0 and purchasable.unlimitedStock == false %}disabled {% endif %}
          value="{{ purchasable.purchasableId }}"&gt;
              {{ purchasable.myProduct.label }} &amp;ndash; {{ purchasable.price|currency(cart.currency) }}
      &lt;/option&gt;
  {% endfor %}
  &lt;/select&gt;
  </code></pre>
  
  <p>This is not going to be a required field, so its possible a user could submit without making a choice.</p>
  
  <p>The error I currently get is:</p>
  
  <pre><code>Not a purchasable ID
  </code></pre>
  
  <p>Which makes complete sense since I am not passing anything to the cart.</p>
  
  <p>Is it best to have a product called "Select" and just have it be zero dollars? Or is there a way - maybe custom plugin - that will skip the input if it has no value?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Or do I force the user to make a choice of "No thanks" (or whatever is applicable) then that option has a price of zero dollars...</p>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>If the user does not make a choice, then Craft gets really angry because I have not passed in a valid purchasable ID (a <code>null</code> value).</p>
  
  <p>In the screenshot, the profile is optional. The user doesn't <em>have</em> to pick one. If they do, all is well since they have chosen a valid purchasable. The selected default value is <code>null</code>.</p>
  
  <p><a href="https://i.sstatic.net/K69jV.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/K69jV.png" alt="enter image description here"></a></p>
  
  <p><strong>EDIT 3</strong></p>
  
  <p>Well, I guess for now I take everything back. I've tried several times to break it but I can't today. I haven't changed anything that I can think of, but this seems to be working. If I don't choose anything, I am taken to the <code>/cart</code> page as expected.</p>
  
  <pre><code>&lt;option value=""&gt;Select Profile&lt;/option&gt;
      {% for profile in profiles %}
          &lt;option value="{{ profile.defaultVariant.purchasableId }}" data-price="{{ profile.defaultVariant.price|currency(cart.currency) }}"&gt;
              {{ profile.title }} &amp;ndash; {% if profile.defaultVariant.price == 0 %} Included with registration {% else %} {{ profile.defaultVariant.price|currency(cart.currency) }}{% endif %}
          &lt;/option&gt;
      {% endfor %}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-02-04T23:00:46.203Z
Comments.Text: Have you tried `value="null"` on the empty option?
Comments.UserDisplayName: Josh Angell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-02-05T16:57:41.597Z
Comments.Text: Hi Josh - no luck. Still get a 500 error.
Comments.UserDisplayName: Damon
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-02-05T17:12:35.917Z
Comments.Text: Perhaps try `false` instead. Shooting in the dark here but it's worth a try! Maybe ask in the commerce channel on Slack as well?
Comments.UserDisplayName: Josh Angell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-02-05T17:38:17.000Z
Comments.Text: Absolutely - I appreciate the suggestions!
Comments.UserDisplayName: Damon
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-12-13T12:30:57.717Z
Comments.Text: "This is not going to be a required field, so its possible a user could submit without making a choice." - How can a user submit the form without a purchasable ID? What does the form do if not adding a product to the cart? (which will require a purchasable ID)
Comments.UserDisplayName: Luke Pearce
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-12-13T14:23:42.453Z
Comments.Text: Hi Luke - I've updated my question with a screen shot to help show what I currently have.
Comments.UserDisplayName: Damon
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-12-13T18:48:08.393Z
Comments.Text: So from your 3rd edit it looks like you found a solution?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-12-13T19:08:06.487Z
Comments.Text: So far so good - can't say I really found anything. :)
  I'll vote to close.
Comments.UserDisplayName: Damon
Tags: <plugin-craftcommerce>
Title: How can I pass a null value to commerce?
ThreadText: # How can I pass a null value to commerce?
  
  (Asked by: username_0 on 2016-02-04)
  
  I am populating a drop-down with product variants like this:
  
  ```
  <select name="mySelect" class="form-control">
  <option value="">Select</option>
  {% for purchasable in product.variants %}
      <option {% if purchasable.stock <= 0 and purchasable.unlimitedStock == false %}disabled {% endif %}
          value="{{ purchasable.purchasableId }}">
              {{ purchasable.myProduct.label }} &ndash; {{ purchasable.price|currency(cart.currency) }}
      </option>
  {% endfor %}
  </select>
  
  ```
  
  This is not going to be a required field, so its possible a user could submit without making a choice.
  
  The error I currently get is:
  
  ```
  Not a purchasable ID
  
  ```
  
  Which makes complete sense since I am not passing anything to the cart.
  
  Is it best to have a product called "Select" and just have it be zero dollars? Or is there a way - maybe custom plugin - that will skip the input if it has no value?
  
  **EDIT**
  
  Or do I force the user to make a choice of "No thanks" (or whatever is applicable) then that option has a price of zero dollars...
  
  **EDIT 2**
  
  If the user does not make a choice, then Craft gets really angry because I have not passed in a valid purchasable ID (a `null` value).
  
  In the screenshot, the profile is optional. The user doesn't *have* to pick one. If they do, all is well since they have chosen a valid purchasable. The selected default value is `null`.
  
  [![enter image description here](https://i.sstatic.net/K69jV.png)](https://i.sstatic.net/K69jV.png)
  
  **EDIT 3**
  
  Well, I guess for now I take everything back. I've tried several times to break it but I can't today. I haven't changed anything that I can think of, but this seems to be working. If I don't choose anything, I am taken to the `/cart` page as expected.
  
  ```
  <option value="">Select Profile</option>
      {% for profile in profiles %}
          <option value="{{ profile.defaultVariant.purchasableId }}" data-price="{{ profile.defaultVariant.price|currency(cart.currency) }}">
              {{ profile.title }} &ndash; {% if profile.defaultVariant.price == 0 %} Included with registration {% else %} {{ profile.defaultVariant.price|currency(cart.currency) }}{% endif %}
          </option>
      {% endfor %}
  
  ```
  
  **Tags:** plugin-craftcommerce
  
  > **Comments:**
  > **username_1**: Have you tried `value="null"` on the empty option?  
  > **username_0**: Hi username_1 - no luck. Still get a 500 error.  
  > **username_1**: Perhaps try `false` instead. Shooting in the dark here but it's worth a try! Maybe ask in the commerce channel on Slack as well?  
  > **username_0**: Absolutely - I appreciate the suggestions!  
  > **username_2**: "This is not going to be a required field, so its possible a user could submit without making a choice." - How can a user submit the form without a purchasable ID? What does the form do if not adding a product to the cart? (which will require a purchasable ID)  
  > **username_0**: Hi username_2 - I've updated my question with a screen shot to help show what I currently have.  
  > **username_3**: So from your 3rd edit it looks like you found a solution?  
  > **username_0**: So far so good - can't say I really found anything. :) I'll vote to close.  
  
  ---
  
  ## 0 answers
  
  