Skip to main content

Add a limited cart total to your cart layout

Show your customers only the total number of products in their cart and exclude abandoned products.

Updated over a week ago

If you limit the number of products displayed in your cart layout to, for example, three items, but the customer has abandoned more than three products, the cart total will not match the total number of products shown.


Add a limited cart total

To total the products shown in your cart layout:

  1. Go to Content > Cart Layout.

  2. Create a new cart layout or edit an existing one.

  3. Insert the following code in the Edit the Cart Layout field before the product For loop:

    {% set cart_total = [] %}
  4. Insert this code inside the For loop:

    {% if cart_total.append((product.uv*product.qty)) %}{% endif %}
  5. Insert this code after in order to show the total:

    {{ cart_total|sum|format_currency(cart.curr) }}
  6. Select SAVE.

Example

You should end up with something like this:

{% set cart_total = [] %}

{% for product in products|limit(max_products_to_show) %}
{% if cart_total.append((product.uv*product.qty)) %}{% endif %}
{% endfor %}

{{ cart_total|sum|format_currency(cart.curr) }}

This is a basic example that excludes most of the code you would use to display product details.

Did this answer your question?