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
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 %}
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!
{% elsif cart.item_count == 0 %}
Have you seen our Single Reference Card Collection?
{% endif %}
{% endif %}
Thanks if you spared a look!
1 Like
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
1 Like