Can Shopify Liquid code update text dynamically without refreshing?

alexlaslau
Tourist
6 0 1

Hey there beautiful people!

Hope you're having a great day!

 

I have a question related to Shopify Liquid Coding, and I'm hoping that you can help me out a little bit!

Basically, I want to have a text dynamically update when a customer increments the quantity of a product on the cart page, without the page restarting. ( Kind of, like, how the price updates on the cart page when someone increases the quantity of a product, without the page restarting.)

 

This is what I've done so far:

 

<div class="cart__footer">
 	      {% if cart.item_count == 1 %}
        <p class="grid__item text-right small--text-center">Add another item for 5% discount!</p>
        {% elsif cart.item_count == 2 %}
        <p class="grid__item text-right small--text-center">Add another item for 10% discount!</p>
        {% elsif cart.item_count == 3 %}
        <p class="grid__item text-right small--text-center">Add another item for 15% discount!</p>
        {% elsif cart.item_count >= 4 %}
        <p class="grid__item text-right small--text-center">Hooray! Maximum discount reached!</p>
        {% endif %}
</div>

 

And this actually works, but only if I refresh the page.

What do you think? And ideas?

Replies 3 (3)

r8r
Shopify Expert
2555 327 940

@alexlaslau – you're half way there, but you need to update the container dynamically using JS, when the input options change. The implementation depends on your theme …

Hope this helps,
Mario

★ Ja, man kann mich buchen; schreib mir eine Nachricht!
★ Hinterlass gerne ein Like und markiere meine Antwort gegebenenfalls als Lösung. Ich freue ich mich immer über eine Spende an die (Kinder)krebshilfe oder eine kleine Aufmerksamkeit.
Studio Mitte
alexlaslau
Tourist
6 0 1

@r8rThank you so much for answering! I'm actually using the Debut theme. How should I address this?

r8r
Shopify Expert
2555 327 940

@alexlaslau – have you solved this yet?

★ Ja, man kann mich buchen; schreib mir eine Nachricht!
★ Hinterlass gerne ein Like und markiere meine Antwort gegebenenfalls als Lösung. Ich freue ich mich immer über eine Spende an die (Kinder)krebshilfe oder eine kleine Aufmerksamkeit.
Studio Mitte