Show the total amount spent by a customer on their account page

You can use the customer.total_spent variable to display the total amount of money spent by a customer on his or her account page. Shopify does not use that variable by default because your customers may have a "Have I really spent that much?" reaction when seeing that total.

It's perfectly okay to add it though, after you have carefully weighed the pros and cons.

To include the total amount spent on a customer account page:

  1. From your Shopify admin, click Online Store, and then click Themes (or press G W T).

  2. Find the theme you want to edit, click the ... button, and then click Edit HTML/CSS.

  3. Under the "Templates" folder, locate and click on customers/account.liquid to open it in the online code editor.

  4. Look for this code in the template:

    
    {% for order in customer.orders %}
    <tr class="{% cycle 'odd', 'even' %} {% if order.cancelled %}cancelled_order{% endif %}">
      <td>{{ order.name | link_to: order.customer_url }}</td>
      <td><span class="note">{{ order.created_at | date: "%b %d, %Y" }}</span></td>
      <td><span class="status_{{ order.financial_status }}">{{ order.financial_status }}</span></td>
      <td><span class="status_{{ order.fulfillment_status }}">{{ order.fulfillment_status }}</span></td>
      <td><span class="total money">{{ order.total_price | money }}</span></td>
    </tr>
    {% endfor %}
    
    
  5. Right below, add this:

    
    <tr>
      <td colspan="4"><em>total spent:</em></td>
      <td><span class="total money">{{ customer.total_spent | money }}</span></td>
    </tr>
    
    

    This will help show you where to add the code:

    Customer acct faq
  6. Save your changes.

The result of that edit in the Couture theme would look like so:

Customer acct faq 2

Want to discuss this page?

Visit the Shopify Community