Trying to get Liquid string text to calculate

LittleStuff
Visitor
1 0 0

So I am trying to use the meta data fields to store text, for example how many items/each are in a variant. I want to take that and divided by the price. So if a product is $100 and there are 10 items than it should give us $10 each.  Because pulling the price dynamically became a problem I opted to create two fields, one for the price of that variant and one for the quantity; and thought maybe it could be improved upon later to pull dynamicly but this would be more static. I can get them to pull up with the following code but I can not for the life of me get any math problem to work.  

 

{% for variant in product.variants %}

  {{ variant.metafields.my_fields.price }}

  {{ variant.metafields.my_fields.quantity }}

{% endfor %}

 

I assumed using the "| divided_by:" from liquid command would work just by pulling the two numbers but it doesn't seem to work. 

 

{% for variant in product.variants %}

{{ variant.metafields.my_fields.diaper_price  | divided_by: variant.metafields.my_fields.diaper_quantity }}

{% endfor %}

 

Thoughts? 

Replies 0 (0)