Answers.Body: <p>Not all orders will necessarily have a craft user associated with the order.</p>
  
  <p>But all orders must have a billing address, so:</p>
  
  <p><code>order.billingAddress.firstName</code> and <code>order.billingAddress.lastName</code> will get you what you need.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-25T07:52:00.663Z
Answers.LastActivityDate: 2018-02-25T07:52:00.663Z
Answers.UserDisplayName: Jeremy Daalder
Answers.Body: <p>I never used Craft commerce so this answer could be totally wrong but just from looking at the docs the <a href="https://craftcommerce.com/docs/order-model#customerid" rel="nofollow noreferrer">Order Model</a> has the attribute <code>customerId</code> and the <code>customer</code> attribute that stores the <a href="https://craftcommerce.com/docs/customer-model" rel="nofollow noreferrer">Customer Model</a> </p>
  
  <blockquote>
    <p><a href="https://craftcommerce.com/docs/order-model#customerid" rel="nofollow noreferrer">customerId</a></p>
    
    <p>The customer record for this order. You can also use customer to get the customer model which can tell you which craft user made the order, as well as access the addresses for this customer.</p>
  </blockquote>
  
  <p>The <code>customer model</code> contains a <a href="https://craftcommerce.com/docs/customer-model#user" rel="nofollow noreferrer">user</a> attribute that stores the default Craft <a href="https://craftcms.com/docs/templating/usermodel" rel="nofollow noreferrer">User Model</a> or null</p>
  
  <blockquote>
    <p><a href="https://craftcommerce.com/docs/customer-model#user" rel="nofollow noreferrer">user</a> </p>
    
    <p>Returns a User Model if the customer is logged in, or null if the customer is a guest.</p>
  </blockquote>
  
  <p>So theoretically you should do something like</p>
  
  <pre><code>{% set customer = order.customer %}
  {% if customer is not null %}
      {% set user = customer.user %}
      {% if user is not null %}
          {{ user.firstName }} {{ user.lastName }}
      {% endif %}
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-24T15:52:28.910Z
Answers.Text: Thanks Robin, I will try your solution. Let you know if this will work.
Answers.UserDisplayName: John Stevens
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-24T14:17:24.367Z
Answers.LastActivityDate: 2018-02-24T14:17:24.367Z
Answers.UserDisplayName: Robin Schambach
Body: <p>I want to output a list of all orders of all customers, including customers first name and last name. But can't get these two elements. </p>
  
  <p>What I have now is:</p>
  
  <pre><code>{% set pastOrders = craft.commerce.orders.find() %}
  {% for order in pastOrders %}
      {% for item in order.lineItems %}
      &lt;tr&gt;
        &lt;td&gt;{{ order.id }}&lt;/td&gt;
        &lt;td&gt;{{ craft.commerce.customer.firstName }}&lt;/td&gt;
        &lt;td&gt;{{ craft.commerce.customer.lastName }}&lt;/td&gt;
        &lt;td&gt;{{ item.description }}&lt;/td&gt;
        &lt;td&gt;{{ order.email }}&lt;/td&gt;
        &lt;td&gt;{{ item.options.evenement }}&lt;/td&gt;
        &lt;td&gt;{{ item.note }}&lt;/td&gt;
        &lt;td&gt;{{order.orderStatus.name}}&lt;/td&gt;
        &lt;td&gt;{{ order.datePaid.localeDate() }}&lt;/td&gt;
      &lt;/tr&gt;
      {% endfor %}
    {% endfor %}
  </code></pre>
  
  <p>But as you may guess, I've got an error in both fields firstName lastName</p>
  
Tags: <plugin-craftcommerce>
Title: Fetching Customer firstName lastName
ThreadText: # Fetching Customer firstName lastName
  
  (Asked by: username_0 on 2018-02-24)
  
  I want to output a list of all orders of all customers, including customers first name and last name. But can't get these two elements.
  
  What I have now is:
  
  ```
  {% set pastOrders = craft.commerce.orders.find() %}
  {% for order in pastOrders %}
      {% for item in order.lineItems %}
      <tr>
        <td>{{ order.id }}</td>
        <td>{{ craft.commerce.customer.firstName }}</td>
        <td>{{ craft.commerce.customer.lastName }}</td>
        <td>{{ item.description }}</td>
        <td>{{ order.email }}</td>
        <td>{{ item.options.evenement }}</td>
        <td>{{ item.note }}</td>
        <td>{{order.orderStatus.name}}</td>
        <td>{{ order.datePaid.localeDate() }}</td>
      </tr>
      {% endfor %}
    {% endfor %}
  
  ```
  
  But as you may guess, I've got an error in both fields firstName lastName
  
  **Tags:** plugin-craftcommerce
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2018-02-25. Score: 3 | Accepted answer
  
  Not all orders will necessarily have a craft user associated with the order.
  
  But all orders must have a billing address, so:
  
  `order.billingAddress.firstName` and `order.billingAddress.lastName` will get you what you need.
  
  
  ---
  
  ### Answer by username_2 on 2018-02-24. Score: 1
  
  I never used Craft commerce so this answer could be totally wrong but just from looking at the docs the [Order Model](https://craftcommerce.com/docs/order-model#customerid) has the attribute `customerId` and the `customer` attribute that stores the [Customer Model](https://craftcommerce.com/docs/customer-model)
  
  > [customerId](https://craftcommerce.com/docs/order-model#customerid)
  >
  > The customer record for this order. You can also use customer to get the customer model which can tell you which craft user made the order, as well as access the addresses for this customer.
  
  The `customer model` contains a [user](https://craftcommerce.com/docs/customer-model#user) attribute that stores the default Craft [User Model](https://craftcms.com/docs/templating/usermodel) or null
  
  > [user](https://craftcommerce.com/docs/customer-model#user)
  >
  > Returns a User Model if the customer is logged in, or null if the customer is a guest.
  
  So theoretically you should do something like
  
  ```
  {% set customer = order.customer %}
  {% if customer is not null %}
      {% set user = customer.user %}
      {% if user is not null %}
          {{ user.firstName }} {{ user.lastName }}
      {% endif %}
  {% endif %}
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks username_2, I will try your solution. Let you know if this will work.  
  
  ---
  
  