# Auto-Update Subtotal When Quantity Changes

**URL:** <https://community.shopify.com/t/auto-update-subtotal-when-quantity-changes/15973>\
**Category:** Technical Q&A\
**Created:** [July 15, 2020, 12:19pm UTC](https://community.shopify.com/t/auto-update-subtotal-when-quantity-changes/15973 "2020-07-15T12:19:27Z")\
**Posts on this page:** 11\
**Page:** 1

## AI-generated summary

Auto-updating the cart subtotal on quantity change without using a paid app, targeting the Launch theme by Pixel Union.

Key approaches:
- Implement Shopify Ajax API for the cart (AJAX = asynchronous updates without page reload).
- Use the open-source “Ajaxify Cart” script from GitHub to add real-time cart updates.

Developments:
- The original poster reports they “fixed it” after integrating Ajaxify Cart and modifying template-cart.liquid.
- However, the shared code snippets are largely commented-out blocks, lacking actual JavaScript/Ajax logic, so others cannot reproduce the solution.

Follow-ups:
- Multiple users indicate the provided code does not auto-update totals, likely due to copying only commented code.
- Requests were made to paste actual working code; another user on the Flow theme asked for guidance on what to change.

Technical notes:
- Shopify Ajax API for cart enables updating line items and subtotal via JavaScript, eliminating the “Update Cart” button.
- Ajaxify Cart is a prebuilt script to wire these behaviors.

Outcome & status:
- Partially resolved for the original poster, but no concrete, reusable solution shared.
- Action items: share the working JS integration steps for Launch, and clarify adaptation steps for Flow.
- Discussion remains open and unresolved for others.

<div class="post-metadata">

**Author:** ![TechSolver](https://avatars.discourse-cdn.com/v4/letter/t/d26b3c/32.png) [@TechSolver](https://community.shopify.com/u/TechSolver)\
**Post date:** [July 15, 2020, 12:19pm UTC](https://community.shopify.com/t/auto-update-subtotal-when-quantity-changes/15973/1 "2020-07-15T12:19:27Z")

</div>

Hey there. I’d like the cart to auto-update the subtotal price each time a customer increases or decreases the quantity and remove the Update Cart button. I know there is an [app](https://apps.shopify.com/cart-auto-update) for this, but I do not want to use a paid app.

I am using Launch theme by Pixel Union, and you can view the cart page of my website by clicking [here](http://techerooco.myshopify.com/cart).

Here is the code of my **template-cart.liquid** :

```markup

  

    

      # {{ 'cart.general.header' | t }}
    

    
      

        {% if cart.item_count > 0 %}

          

          {% if section.settings.show_shipping_calculator and cart.requires_shipping %}
            {% include 'shipping-calculator' %}
          {% endif %}
        {% else %}
          

{{ 'cart.general.empty' | t }} {{ 'cart.general.continue' | t }}

        {% endif %}
      

    

  

{% schema %}
{
  "name": "Cart page",
  "settings": [
    {
      "type": "checkbox",
      "id": "order_notes",
      "label": "Enable order notes",
      "default": false
    },
    {
      "type": "header",
      "content": "Shipping calculator"
    },
    {
      "type": "checkbox",
      "id": "show_shipping_calculator",
      "label": "Enable",
      "default": false
    },
    {
      "type": "text",
      "id": "shipping_calculator_default_country",
      "label": "Default country",
      "default": "United States"
    }
  ]
}
{% endschema %}

```

Thank you!

---

<div class="post-metadata">

**Author:** ![Propero](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/propero/32/369419_2.png) [@Propero](https://community.shopify.com/u/Propero)\
**Post date:** [July 15, 2020, 12:37pm UTC](https://community.shopify.com/t/auto-update-subtotal-when-quantity-changes/15973/2 "2020-07-15T12:37:07Z")

</div>

@TechSolver ,

You can implement Ajax support using Shopify ajax API, here is detail for you [https://shopify.dev/docs/themes/ajax-api/reference/cart](https://shopify.dev/docs/themes/ajax-api/reference/cart)

Alternatively you can look for free apps on app store and if both doesn’t solve the purpose, please feel free to DM for a custom solution

---

<div class="post-metadata">

**Author:** ![TechSolver](https://avatars.discourse-cdn.com/v4/letter/t/d26b3c/32.png) [@TechSolver](https://community.shopify.com/u/TechSolver)\
**Post date:** [July 15, 2020, 12:38pm UTC](https://community.shopify.com/t/auto-update-subtotal-when-quantity-changes/15973/3 "2020-07-15T12:38:18Z")

</div>

@Propero I am not sure how to. I could not find any free apps.

Can you please help me?

---

<div class="post-metadata">

**Author:** ![Propero](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/propero/32/369419_2.png) [@Propero](https://community.shopify.com/u/Propero)\
**Post date:** [July 15, 2020, 12:44pm UTC](https://community.shopify.com/t/auto-update-subtotal-when-quantity-changes/15973/4 "2020-07-15T12:44:13Z")

</div>

try this Ajaxify Cart. Which theme are you using?

---

<div class="post-metadata">

**Author:** ![TechSolver](https://avatars.discourse-cdn.com/v4/letter/t/d26b3c/32.png) [@TechSolver](https://community.shopify.com/u/TechSolver)\
**Post date:** [July 15, 2020, 12:48pm UTC](https://community.shopify.com/t/auto-update-subtotal-when-quantity-changes/15973/5 "2020-07-15T12:48:10Z")

</div>

> I am using Launch theme by Pixel Union.

@Propero I already stated what theme I’m using in my first post. I don’t know what code to use, can you please tell me?

---

<div class="post-metadata">

**Author:** ![Propero](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/propero/32/369419_2.png) [@Propero](https://community.shopify.com/u/Propero)\
**Post date:** [July 15, 2020, 2:35pm UTC](https://community.shopify.com/t/auto-update-subtotal-when-quantity-changes/15973/6 "2020-07-15T14:35:11Z")

</div>

Here is the code if you wanna try your hands on [https://github.com/carolineschnapp/ajaxify-cart](https://github.com/carolineschnapp/ajaxify-cart)

All the best!

---

<div class="post-metadata">

**Author:** ![TechSolver](https://avatars.discourse-cdn.com/v4/letter/t/d26b3c/32.png) [@TechSolver](https://community.shopify.com/u/TechSolver)\
**Post date:** [July 15, 2020, 8:24pm UTC](https://community.shopify.com/t/auto-update-subtotal-when-quantity-changes/15973/7 "2020-07-15T20:24:24Z")

</div>

@Propero fixed it. Here’s the modified code for anyone interested:

```markup

  

    

      # {{ 'cart.general.header' | t }}
    

    
      

        {% if cart.item_count > 0 %}

          

          {% if section.settings.show_shipping_calculator and cart.requires_shipping %}
            {% include 'shipping-calculator' %}
          {% endif %}
        {% else %}
          

{{ 'cart.general.empty' | t }} {{ 'cart.general.continue' | t }}

        {% endif %}
      

    

  

{% schema %}
{
  "name": "Cart page",
  "settings": [
    {
      "type": "checkbox",
      "id": "order_notes",
      "label": "Enable order notes",
      "default": false
    },
    {
      "type": "header",
      "content": "Shipping calculator"
    },
    {
      "type": "checkbox",
      "id": "show_shipping_calculator",
      "label": "Enable",
      "default": false
    },
    {
      "type": "text",
      "id": "shipping_calculator_default_country",
      "label": "Default country",
      "default": "United States"
    }
  ]
}
{% endschema %}

{% comment %}

{% endcomment %}

```

---

<div class="post-metadata">

**Author:** ![TechSolver](https://avatars.discourse-cdn.com/v4/letter/t/d26b3c/32.png) [@TechSolver](https://community.shopify.com/u/TechSolver)\
**Post date:** [July 15, 2020, 8:41pm UTC](https://community.shopify.com/t/auto-update-subtotal-when-quantity-changes/15973/8 "2020-07-15T20:41:36Z")

</div>

Thanks @Propero

Insert the following code at the bottom of **template-cart.liquid** :

```markup
{% comment %}

{% endcomment %}

```

---

<div class="post-metadata">

**Author:** ![liuyanyan](https://avatars.discourse-cdn.com/v4/letter/l/dfb087/32.png) [@liuyanyan](https://community.shopify.com/u/liuyanyan)\
**Post date:** [July 22, 2021, 8:43am UTC](https://community.shopify.com/t/auto-update-subtotal-when-quantity-changes/15973/9 "2021-07-22T08:43:20Z")

</div>

hello i have tried your code but not work my cart still can not automatically update price when you changed the quantity

could you help me?

many thanks

---

<div class="post-metadata">

**Author:** ![Propero](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/propero/32/369419_2.png) [@Propero](https://community.shopify.com/u/Propero)\
**Post date:** [July 22, 2021, 9:19am UTC](https://community.shopify.com/t/auto-update-subtotal-when-quantity-changes/15973/10 "2021-07-22T09:19:06Z")

</div>

@liuyanyan please paste your code…I think you have added commented code

---

<div class="post-metadata">

**Author:** ![salonpro](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@salonpro](https://community.shopify.com/u/salonpro)\
**Post date:** [February 10, 2023, 3:15pm UTC](https://community.shopify.com/t/auto-update-subtotal-when-quantity-changes/15973/11 "2023-02-10T15:15:11Z")

</div>

Hi,

I am on the flow theme and I have no idea what to change the code to so my cart auto updates could you help me?
