If statement using Settings.json

Solved
NelsonAF
Shopify Partner
6 1 0

I'm trying to display a message in the cart based on theme settings. This is all set up using schema.json. Everything is working except the cart price. Where it says 5000 I would like to use the theme setting "settings.bonus_entries_purchase". But when saving it gives liquid errors. 

  {% if settings.bonus_entries_box == true and cart.total_price < 5000 %}
     <div class="cart-bonus-offer">
  <div class="cart-bonus-img"><img src="https://cdn.shopify.com/s/files/1/0064/2980/2561/t/1/assets/1558892373.gif" alt=""></div>
  <h3>GET {{settings.bonus_entries_amount}} BONUS ENTRIES!!</h3>
	<p>When you purchase ${{settings.bonus_entries_purchase | divided_by: 100}} or more. Entries are automatically added to your account.</p>
    <p class="cart-bonus-disclaimer">Ends {{settings.bonus_entries_date}}.</p> 
    </div>
  {%- endif -%}
Accepted Solution (1)

Accepted Solutions
NelsonAF
Shopify Partner
6 1 0

This is an accepted solution.

It lets me save the file but in the browser says "Liquid error (sections/cart-template.liquid line 32): comparison of Integer with String failed"

View solution in original post

Replies 3 (3)
PaulNewton
Shopify Partner
3491 233 677

@NelsonAF wrote:

 But when saving it gives liquid errors.

And those errors are???

 

This is all set up using schema.json

Are you putting your code in that schema file?, or the cart template where it should be?

Schema is for a schema of deterministic properties in a JSON format exposed as settings it doesn't not consume liquid logic.

 

What important thing did you learn this Black Friday?


Answers powered by coffee Buy Paul a ☕ Coffee for more answers or donate to eff.org

Problem Solved? ✔Accept and Like solutions to help future merchants

Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
NelsonAF
Shopify Partner
6 1 0

This is an accepted solution.

It lets me save the file but in the browser says "Liquid error (sections/cart-template.liquid line 32): comparison of Integer with String failed"

View solution in original post

PaulNewton
Shopify Partner
3491 233 677

Your going to have to try an isolate the problem.

Remove the suspect code does the error still appear? Then the error is elsewhere

If the error is still check that the related settings are using the number type:

https://shopify.dev/themes/architecture/settings/input-settings#numbe

If not you may need to coerce the strings to a number, topic discussed elsewhere on the forums.

What important thing did you learn this Black Friday?


Answers powered by coffee Buy Paul a ☕ Coffee for more answers or donate to eff.org

Problem Solved? ✔Accept and Like solutions to help future merchants

Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com