Answers.Body: <p>Figured out the issue. In order to work with a matrix field, you also have to include the block type and the sortOrder in the POST data.</p>
  <pre><code>{{ input('hidden', 'fields[manifest][sortOrder][]', '__counter__') }}
  {{ input('hidden', 'fields[manifest][blocks][new1][type]', 'manifest') }}
      &lt;div class=&quot;form-group&quot;&gt;
        {% tag 'input' with {
            type: 'email',
            name: 'fields[manifest][blocks][new1][fields][firstName]',
            value: &quot;&quot;,
            placeholder: 'First Name'|t,
            class: ['form-control']
        } %}{% endtag %}
        &lt;label for=&quot;fields[manifest][blocks][new1][fields][firstName]&quot;&gt;{{ 'First Name'|t }}&lt;/label&gt;
      &lt;/div&gt;
      &lt;div class=&quot;form-group&quot;&gt;
        {% tag 'input' with {
            type: 'email',
            name: 'fields[manifest][blocks][new1][fields][lastName]',
            value: &quot;&quot;,
            placeholder: 'First Name'|t,
            class: ['form-control']
        } %}{% endtag %}
        &lt;label for=&quot;fields[manifest][blocks][new1][fields][lastName]&quot;&gt;{{ 'Last Name'|t }}&lt;/label&gt;
      &lt;/div&gt;
      &lt;div class=&quot;form-group&quot;&gt;
        {% tag 'input' with {
            type: 'email',
            name: 'fields[manifest][blocks][new1][fields][email]',
            value: &quot;&quot;,
            placeholder: 'Email'|t,
            class: ['form-control']
        } %}{% endtag %}
        &lt;label for=&quot;fields[manifest][blocks][new1][fields][email]&quot;&gt;{{ 'Email'|t }}&lt;/label&gt;
      &lt;/div&gt;
      &lt;div class=&quot;form-group&quot;&gt;
        {% tag 'input' with {
            type: 'email',
            name: 'fields[manifest][blocks][new1][fields][phone]',
            value: &quot;&quot;,
            placeholder: 'Email'|t,
            class: ['form-control']
        } %}{% endtag %}
        &lt;label for=&quot;fields[manifest][blocks][new1][fields][phone]&quot;&gt;{{ 'Phone #'|t }}&lt;/label&gt;
      &lt;/div&gt;
  </code></pre>
  <p>Adding those fields solved the problem.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-04-11T02:43:00.507Z
Answers.LastActivityDate: 2023-04-11T02:43:00.507Z
Answers.UserDisplayName: Peter Adams
Body: <p>When I follow the documented process of <a href="https://craftcms.com/docs/commerce/4.x/orders-carts.html#storing-data-in-custom-fields" rel="nofollow noreferrer">populating custom fields</a> with an update cart call, I'm able to get values for lightswitches and text fields to populate just fine. I cannot, however, get the submitted fields to carry over to the order/cart when I try to populate them into a Matrix field.</p>
  <p>Is this possible with Commerce?</p>
  <p>In this case, I'm trying to capture a manifest of individuals (name, email, phone) based on the quantity.</p>
  <p>If I try to add:</p>
  <pre><code>    &lt;div class=&quot;form-group&quot;&gt;
        {% tag 'input' with {
            type: 'email',
            name: 'fields[manifest][blocks][new1][fields][firstName]',
            value: &quot;&quot;,
            placeholder: 'First Name'|t,
            class: ['form-control']
        } %}{% endtag %}
        &lt;label for=&quot;fields[manifest][blocks][new1][fields][firstName]&quot;&gt;{{ 'First Name'|t }}&lt;/label&gt;
      &lt;/div&gt;
      &lt;div class=&quot;form-group&quot;&gt;
        {% tag 'input' with {
            type: 'email',
            name: 'fields[manifest][blocks][new1][fields][lastName]',
            value: &quot;&quot;,
            placeholder: 'First Name'|t,
            class: ['form-control']
        } %}{% endtag %}
        &lt;label for=&quot;fields[manifest][blocks][new1][fields][lastName]&quot;&gt;{{ 'Last Name'|t }}&lt;/label&gt;
      &lt;/div&gt;
      &lt;div class=&quot;form-group&quot;&gt;
        {% tag 'input' with {
            type: 'email',
            name: 'fields[manifest][blocks][new1][fields][email]',
            value: &quot;&quot;,
            placeholder: 'Email'|t,
            class: ['form-control']
        } %}{% endtag %}
        &lt;label for=&quot;fields[manifest][blocks][new1][fields][email]&quot;&gt;{{ 'Email'|t }}&lt;/label&gt;
      &lt;/div&gt;
      &lt;div class=&quot;form-group&quot;&gt;
        {% tag 'input' with {
            type: 'email',
            name: 'fields[manifest][blocks][new1][fields][phone]',
            value: &quot;&quot;,
            placeholder: 'Email'|t,
            class: ['form-control']
        } %}{% endtag %}
        &lt;label for=&quot;fields[manifest][blocks][new1][fields][phone]&quot;&gt;{{ 'Phone #'|t }}&lt;/label&gt;
      &lt;/div&gt;
  </code></pre>
  <p>If I replace <code>new1</code> with a unique key to identify each one, I would expect it to add each of the values to a matching block for the manifest custom field but it doesn't seem to be capturing the input at all.</p>
  <p>Craft CMS: 4.4.6.1<br>
  Craft Commerce: 4.2.6</p>
  
Tags: <plugin-craftcommerce2>
Title: Adding purchaseables to cart with custom matrix field
ThreadText: # Adding purchaseables to cart with custom matrix field
  
  (Asked by: username_0 on 2023-04-10)
  
  When I follow the documented process of [populating custom fields](https://craftcms.com/docs/commerce/4.x/orders-carts.html#storing-data-in-custom-fields) with an update cart call, I'm able to get values for lightswitches and text fields to populate just fine. I cannot, however, get the submitted fields to carry over to the order/cart when I try to populate them into a Matrix field.
  
  Is this possible with Commerce?
  
  In this case, I'm trying to capture a manifest of individuals (name, email, phone) based on the quantity.
  
  If I try to add:
  
  ```
      <div class="form-group">
        {% tag 'input' with {
            type: 'email',
            name: 'fields[manifest][blocks][new1][fields][firstName]',
            value: "",
            placeholder: 'First Name'|t,
            class: ['form-control']
        } %}{% endtag %}
        <label for="fields[manifest][blocks][new1][fields][firstName]">{{ 'First Name'|t }}</label>
      </div>
      <div class="form-group">
        {% tag 'input' with {
            type: 'email',
            name: 'fields[manifest][blocks][new1][fields][lastName]',
            value: "",
            placeholder: 'First Name'|t,
            class: ['form-control']
        } %}{% endtag %}
        <label for="fields[manifest][blocks][new1][fields][lastName]">{{ 'Last Name'|t }}</label>
      </div>
      <div class="form-group">
        {% tag 'input' with {
            type: 'email',
            name: 'fields[manifest][blocks][new1][fields][email]',
            value: "",
            placeholder: 'Email'|t,
            class: ['form-control']
        } %}{% endtag %}
        <label for="fields[manifest][blocks][new1][fields][email]">{{ 'Email'|t }}</label>
      </div>
      <div class="form-group">
        {% tag 'input' with {
            type: 'email',
            name: 'fields[manifest][blocks][new1][fields][phone]',
            value: "",
            placeholder: 'Email'|t,
            class: ['form-control']
        } %}{% endtag %}
        <label for="fields[manifest][blocks][new1][fields][phone]">{{ 'Phone #'|t }}</label>
      </div>
  
  ```
  
  If I replace `new1` with a unique key to identify each one, I would expect it to add each of the values to a matching block for the manifest custom field but it doesn't seem to be capturing the input at all.
  
  Craft CMS: 4.4.6.1  
  Craft Commerce: 4.2.6
  
  **Tags:** plugin-craftcommerce2
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2023-04-11. Score: 2 | Accepted answer
  
  Figured out the issue. In order to work with a matrix field, you also have to include the block type and the sortOrder in the POST data.
  
  ```
  {{ input('hidden', 'fields[manifest][sortOrder][]', '__counter__') }}
  {{ input('hidden', 'fields[manifest][blocks][new1][type]', 'manifest') }}
      <div class="form-group">
        {% tag 'input' with {
            type: 'email',
            name: 'fields[manifest][blocks][new1][fields][firstName]',
            value: "",
            placeholder: 'First Name'|t,
            class: ['form-control']
        } %}{% endtag %}
        <label for="fields[manifest][blocks][new1][fields][firstName]">{{ 'First Name'|t }}</label>
      </div>
      <div class="form-group">
        {% tag 'input' with {
            type: 'email',
            name: 'fields[manifest][blocks][new1][fields][lastName]',
            value: "",
            placeholder: 'First Name'|t,
            class: ['form-control']
        } %}{% endtag %}
        <label for="fields[manifest][blocks][new1][fields][lastName]">{{ 'Last Name'|t }}</label>
      </div>
      <div class="form-group">
        {% tag 'input' with {
            type: 'email',
            name: 'fields[manifest][blocks][new1][fields][email]',
            value: "",
            placeholder: 'Email'|t,
            class: ['form-control']
        } %}{% endtag %}
        <label for="fields[manifest][blocks][new1][fields][email]">{{ 'Email'|t }}</label>
      </div>
      <div class="form-group">
        {% tag 'input' with {
            type: 'email',
            name: 'fields[manifest][blocks][new1][fields][phone]',
            value: "",
            placeholder: 'Email'|t,
            class: ['form-control']
        } %}{% endtag %}
        <label for="fields[manifest][blocks][new1][fields][phone]">{{ 'Phone #'|t }}</label>
      </div>
  
  ```
  
  Adding those fields solved the problem.
  
  
  ---
  
  