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. Find the theme you want to edit, click Actions, and then click Edit HTML/CSS.

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

  3. Look for this code in the template:

    {% for order in customer.orders %}
    <tr class="{% cycle 'odd', 'even' %} {% if order.cancelled %}cancelled_order{% endif %}">
      <td>{{ | 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>
    {% endfor %}
  4. Right below, add this:

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

    This will help show you where to add the code:

    Customer acct faq
  5. 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