App reviews, troubleshooting, and recommendations
Hi guys,
I am using a theme which I have confirmed, supports the use of custom liquid sections. I am trying to run the code:
{% if cart.items_subtotal_price <= 7.98 %}
{% if cart.item_count == 3 %}
Add one more Single Reference Card to get £3.97 off!
{% elsif cart.item_count == 2 %}
Add two more Single Reference Cards to get £3.97 off!
{% elsif cart.item_count == 1 %}
Add three more Single Reference Cards to get £3.97 off!
{% endif %}
{% endif %}
But when I try to test it, it doesn't work as expected. I am trying to use the code to capture the amount of items in cart and total price and announce that if they add x more items (to make total of 4 items) to the cart then they get a discount.
Anyone able to spot any errors and suggest a quick fix?
I am new to Liquid so if it is a rookie error then I apologise
Solved! Go to the solution
This is an accepted solution.
I found that the error was that I hadn't used the right format for price and I hadn't classified the "add xxx" as a text box so it now works with code:
{% if cart.items_subtotal_price < 799 %}
{% if cart.item_count == 3 %}
<p style="text-align: center;">Add one more Single Reference Card to get £3.97 off!</p>
{% elsif cart.item_count == 2 %}
<p style="text-align: center;">Add two more Single Reference Cards to get £3.97 off!</p>
{% elsif cart.item_count == 1 %}
<p style="text-align: center;">Add three more Single Reference Cards to get £3.97 off!</p>
{% elsif cart.item_count == 0 %}
<p style="text-align: center;">Have you seen our Single Reference Card Collection?</p>
{% endif %}
{% endif %}
Thanks if you spared a look!
This is an accepted solution.
I found that the error was that I hadn't used the right format for price and I hadn't classified the "add xxx" as a text box so it now works with code:
{% if cart.items_subtotal_price < 799 %}
{% if cart.item_count == 3 %}
<p style="text-align: center;">Add one more Single Reference Card to get £3.97 off!</p>
{% elsif cart.item_count == 2 %}
<p style="text-align: center;">Add two more Single Reference Cards to get £3.97 off!</p>
{% elsif cart.item_count == 1 %}
<p style="text-align: center;">Add three more Single Reference Cards to get £3.97 off!</p>
{% elsif cart.item_count == 0 %}
<p style="text-align: center;">Have you seen our Single Reference Card Collection?</p>
{% endif %}
{% endif %}
Thanks if you spared a look!
Good work,
I found that the error was that I hadn't used the right format for price
To clarify for others the gotcha is prices, aka |money , are represented as cents , pennies , in shopify-liquid in themes.
https://shopify.dev/docs/api/liquid/objects/money#money-referencing-money-objects-directly
Contact paull.newton+shopifyforum@gmail.com for the solutions you need
Save time & money ,Ask Questions The Smart Way
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Thank Paul with a ☕ Coffee for more answers or donate to eff.org
By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024