Answers.Body: <p>The trouble you are running into is trying to add a string value to an integer to get your total.</p>
  
  <p>You have to use <code>order.totalPrice</code> without the <code>currency</code> filter to be able to add all the values together.</p>
  
  <pre><code>{% set cart = craft.commerce.cart %}
  {% set totalOrders = 0 %}
  
  {% for order in craft.commerce.orders.customer( craft.commerce.customer ).find() %}
    {% set totalOrders = totalOrders + order.totalPrice %}
  {% endfor %}
  
  {{ totalOrders|currency( cart.currency ) }}
  </code></pre>
  
  <p>Only apply the <code>currency</code> filter once all the calculations are complete.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-30T18:43:44.533Z
Answers.LastActivityDate: 2016-05-30T18:43:44.533Z
Answers.UserDisplayName: Luke Pearce
Body: <p>I want to show a user the total sum of all their orders.
  My problem: In the result the decimals are "lost" and always show as zeros.</p>
  
  <pre><code>{% set totalOrders = 0 %}
  {% for order in craft.commerce.orders.customer(craft.commerce.customer).find() %}
    {% set totalOrders = totalOrders + order.totalPrice|currency(order.currency) %}
  {% endfor %}
  {{ totalOrders|currency(order.currency) }}
  </code></pre>
  
Tags: <templating><plugin-craftcommerce><order>
Title: Decimals missing in result after adding up order totals for a customer
ThreadText: # Decimals missing in result after adding up order totals for a customer
  
  (Asked by: username_0 on 2016-05-30)
  
  I want to show a user the total sum of all their orders.
  My problem: In the result the decimals are "lost" and always show as zeros.
  
  ```
  {% set totalOrders = 0 %}
  {% for order in craft.commerce.orders.customer(craft.commerce.customer).find() %}
    {% set totalOrders = totalOrders + order.totalPrice|currency(order.currency) %}
  {% endfor %}
  {{ totalOrders|currency(order.currency) }}
  
  ```
  
  **Tags:** templating, plugin-craftcommerce, order
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-05-30. Score: 3 | Accepted answer
  
  The trouble you are running into is trying to add a string value to an integer to get your total.
  
  You have to use `order.totalPrice` without the `currency` filter to be able to add all the values together.
  
  ```
  {% set cart = craft.commerce.cart %}
  {% set totalOrders = 0 %}
  
  {% for order in craft.commerce.orders.customer( craft.commerce.customer ).find() %}
    {% set totalOrders = totalOrders + order.totalPrice %}
  {% endfor %}
  
  {{ totalOrders|currency( cart.currency ) }}
  
  ```
  
  Only apply the `currency` filter once all the calculations are complete.
  
  
  ---
  
  