Auto-Update Subtotal When Quantity Changes

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.

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 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.

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


  

    

      # {{ '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!

@TechSolver ,

You can implement Ajax support using Shopify ajax API, here is detail for you 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

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

Can you please help me?

try this Ajaxify Cart. Which theme are you using?

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?

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

All the best!

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


  

    

      # {{ '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 %}

Thanks @Propero

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

{% comment %}

{% endcomment %}

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

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

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?