Answers.Body: <p>There are many ways to skin this particular cat I'm sure, but the easiest way is just to use the manual payment gateway and a/some custom field(s) on your order to record the purchase order details.</p>
  
  <p>Whenever you call the <code>updateCart</code> controller, from your input form where you gather the PO details, you can then pass in the POST parameters as <code>fields[purchaseOrderDetails]</code> to save the data to your field named <code>purchaseOrderDetails</code> for later processing.</p>
  
  <p><strong>Update using your code above:</strong></p>
  
  <pre><code>{% if not craft.commerce.paymentMethods|length %}
      &lt;p&gt;No payment methods available.&lt;/p&gt;
  {% endif %}
  
  {% if craft.commerce.paymentMethods|length %}
      &lt;form method="POST" id="paymentMethod" class="form-inline"&gt;
  
          &lt;input type="hidden" name="action" value="commerce/cart/updateCart"&gt;
          &lt;input type="hidden" name="redirect" value="commerce/checkout/payment"&gt;
  
          {{ getCsrfInput() }}
  
          &lt;label for=""&gt;Payment Method&lt;/label&gt;&lt;br &gt;
          &lt;select id="paymentMethodId" name="paymentMethodId"
                  class="form-control"&gt;
              {% for id,name in craft.commerce.paymentMethods %}
                  &lt;option value="{{ id }}"
                          {% if id == cart.paymentMethod.id %}selected{% endif %}&gt;{{ name }}&lt;/option&gt;
              {% endfor %}
          &lt;/select&gt;
  
          &lt;div class="purchase-order-block"&gt;
              &lt;label&gt;Purchase Order Number&lt;/label&gt;
              &lt;input type="text" name="fields[purchaseOrder]"
                  placeholder="Purchase Order"
                  class="purchase-order-field"
                  value="{{ cart.purchaseOrder }}"&gt;
          &lt;/div&gt;
  
      &lt;/form&gt;
  {% endif %}
  </code></pre>
  
  <p>All I have really done here is change how you're referencing the filed  on our order (which must have a handle of <code>purchaseOrder</code> for the above to work).  And I am presuming you have the cart available in <code>cart</code> obviously.</p>
  
  <p>Don't forget to accept the answer if it gets you going!
  Untested, but that's pretty much it, you were almost there really!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-20T05:53:17.750Z
Answers.Text: One more thing - with these sorts of fields I like to make them incognito fields (indeed I did a PR wit this to improve their behaviour, but hasn't been merged yet) - https://github.com/mmikkel/IncognitoField-Craft - basically this can make a field non-editable to your order processing people can't accidentally over-write the customer submitted data.
Answers.UserDisplayName: Jeremy Daalder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-20T16:48:30.377Z
Answers.Text: I may be approaching this wrong.  I am wanting the PO to listed in the Commerce>Orders> so that when I am logged in I will be able to see the PO.  Right now the field is blank.
Answers.UserDisplayName: user1663102
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-21T00:08:16.727Z
Answers.Text: Custom fields on orders should be visible in the back end, if that is what you mean.  Basically, you can define any custom field type you want, and then you add it to the order fields in Commerce->settings.  You can do all the normal field layout stuff (tabs etc) - and these fields will appear below the order when you're looking at that order in the commerce back end.
  
  If you want it listed on just the Commerce -> Orders page itself, rather than a specific order, just click on the cog icon belowyour order statusses and add it as a column there.
Answers.UserDisplayName: Jeremy Daalder
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-09T23:34:28.163Z
Answers.LastActivityDate: 2016-05-19T23:25:51.980Z
Answers.LastEditDate: 2016-05-19T23:25:51.980Z
Answers.UserDisplayName: Jeremy Daalder
Body: <p>I read through the docs for Commerce, but could not figure out how to use Purchase Orders with Commerce.  I am still working through the trial version to make sure Commerce can do what the client is wanting.  I know the paid version has a manual gateway.  Want to make sure it will allow the collection of a Purchase Order.</p>
  
  <p>Jeremy I tried what you suggest.  Here is what I have...</p>
  
  <pre><code>    {% if not craft.commerce.paymentMethods|length %}
          &lt;p&gt;No payment methods available.&lt;/p&gt;
      {% endif %}
  
      {% if craft.commerce.paymentMethods|length %}
          &lt;form method="POST" id="paymentMethod" class="form-inline"&gt;
  
              &lt;input type="hidden" name="action" value="commerce/cart/updateCart"&gt;
              &lt;input type="hidden" name="redirect" value="commerce/checkout/payment"&gt;
  
              {{ getCsrfInput() }}
  
              &lt;label for=""&gt;Payment Method&lt;/label&gt;&lt;br &gt;
              &lt;select id="paymentMethodId" name="paymentMethodId"
                      class="form-control"&gt;
                  {% for id,name in craft.commerce.paymentMethods %}
                      &lt;option value="{{ id }}"
                              {% if id == cart.paymentMethod.id %}selected{% endif %}&gt;{{ name }}&lt;/option&gt;
                  {% endfor %}
              &lt;/select&gt;
  
              &lt;div class="purchase-order-block"&gt;
                  &lt;label&gt;Purchase Order Number&lt;/label&gt;
                  &lt;input type="text" name="purchaseOrder"
                      placeholder="Purchase Order"
                      class="purchase-order-field"
                      value="{{ formValues.lastName }}"&gt;
              &lt;/div&gt;
  
          &lt;/form&gt;
      {% endif %}
  </code></pre>
  
  <p>I am not surprised that it is not working as I really don't know what I am doing here.  Sure my form is wrong.  Any suggestions.  With your help on other areas I am almost finished.  This is the last thing I need to do and I will be finished.  Any suggestions or help will be greatly appreciated.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-05-19T23:26:10.573Z
Comments.Text: See updated answer below
Comments.UserDisplayName: Jeremy Daalder
Tags: <plugin-craftcommerce>
Title: Purchase Order in Craft Commerce
ThreadText: # Purchase Order in Craft Commerce
  
  (Asked by: username_0 on 2016-05-09)
  
  I read through the docs for Commerce, but could not figure out how to use Purchase Orders with Commerce. I am still working through the trial version to make sure Commerce can do what the client is wanting. I know the paid version has a manual gateway. Want to make sure it will allow the collection of a Purchase Order.
  
  username_1 I tried what you suggest. Here is what I have...
  
  ```
      {% if not craft.commerce.paymentMethods|length %}
          <p>No payment methods available.</p>
      {% endif %}
  
      {% if craft.commerce.paymentMethods|length %}
          <form method="POST" id="paymentMethod" class="form-inline">
  
              <input type="hidden" name="action" value="commerce/cart/updateCart">
              <input type="hidden" name="redirect" value="commerce/checkout/payment">
  
              {{ getCsrfInput() }}
  
              <label for="">Payment Method</label><br >
              <select id="paymentMethodId" name="paymentMethodId"
                      class="form-control">
                  {% for id,name in craft.commerce.paymentMethods %}
                      <option value="{{ id }}"
                              {% if id == cart.paymentMethod.id %}selected{% endif %}>{{ name }}</option>
                  {% endfor %}
              </select>
  
              <div class="purchase-order-block">
                  <label>Purchase Order Number</label>
                  <input type="text" name="purchaseOrder"
                      placeholder="Purchase Order"
                      class="purchase-order-field"
                      value="{{ formValues.lastName }}">
              </div>
  
          </form>
      {% endif %}
  
  ```
  
  I am not surprised that it is not working as I really don't know what I am doing here. Sure my form is wrong. Any suggestions. With your help on other areas I am almost finished. This is the last thing I need to do and I will be finished. Any suggestions or help will be greatly appreciated.
  
  **Tags:** plugin-craftcommerce
  
  > **Comments:**
  > **username_1**: See updated answer below  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-05-09. Score: 1 | Accepted answer
  
  There are many ways to skin this particular cat I'm sure, but the easiest way is just to use the manual payment gateway and a/some custom field(s) on your order to record the purchase order details.
  
  Whenever you call the `updateCart` controller, from your input form where you gather the PO details, you can then pass in the POST parameters as `fields[purchaseOrderDetails]` to save the data to your field named `purchaseOrderDetails` for later processing.
  
  **Update using your code above:**
  
  ```
  {% if not craft.commerce.paymentMethods|length %}
      <p>No payment methods available.</p>
  {% endif %}
  
  {% if craft.commerce.paymentMethods|length %}
      <form method="POST" id="paymentMethod" class="form-inline">
  
          <input type="hidden" name="action" value="commerce/cart/updateCart">
          <input type="hidden" name="redirect" value="commerce/checkout/payment">
  
          {{ getCsrfInput() }}
  
          <label for="">Payment Method</label><br >
          <select id="paymentMethodId" name="paymentMethodId"
                  class="form-control">
              {% for id,name in craft.commerce.paymentMethods %}
                  <option value="{{ id }}"
                          {% if id == cart.paymentMethod.id %}selected{% endif %}>{{ name }}</option>
              {% endfor %}
          </select>
  
          <div class="purchase-order-block">
              <label>Purchase Order Number</label>
              <input type="text" name="fields[purchaseOrder]"
                  placeholder="Purchase Order"
                  class="purchase-order-field"
                  value="{{ cart.purchaseOrder }}">
          </div>
  
      </form>
  {% endif %}
  
  ```
  
  All I have really done here is change how you're referencing the filed on our order (which must have a handle of `purchaseOrder` for the above to work). And I am presuming you have the cart available in `cart` obviously.
  
  Don't forget to accept the answer if it gets you going!
  Untested, but that's pretty much it, you were almost there really!
  
  > **Comments:**
  > **username_1**: One more thing - with these sorts of fields I like to make them incognito fields (indeed I did a PR wit this to improve their behaviour, but hasn't been merged yet) - https://github.com/mmikkel/IncognitoField-Craft - basically this can make a field non-editable to your order processing people can't accidentally over-write the customer submitted data.  
  > **username_0**: I may be approaching this wrong.  I am wanting the PO to listed in the Commerce>Orders> so that when I am logged in I will be able to see the PO.  Right now the field is blank.  
  > **username_1**: Custom fields on orders should be visible in the back end, if that is what you mean.  Basically, you can define any custom field type you want, and then you add it to the order fields in Commerce->settings.  You can do all the normal field layout stuff (tabs etc) - and these fields will appear below the order when you're looking at that order in the commerce back end.  If you want it listed on just the Commerce -> Orders page itself, rather than a specific order, just click on the cog icon belowyour order statusses and add it as a column there.  
  
  ---
  
  