Solved

How do I calculate with metafields in custom liquid?

DreamDrops
Tourist
10 0 1

Hello guys,

 

I want to do this math tasks with this fields in custom liquid:

{{product.metafields.custom.markenpreistest | metafield_text}}

minus

{{product.price | money}}

 

how i have to write the code, so this works?


Accepted Solution (1)

hamzaadeel
Shopify Partner
11 2 4

This is an accepted solution.

{% assign markenpreistest = product.metafields.custom.markenpreistest | metafield_text %}
{% assign price = product.price | money %}

{% assign result = markenpreistest | minus: price %}

The result is: {{ result }}

View solution in original post

Replies 2 (2)

hamzaadeel
Shopify Partner
11 2 4

This is an accepted solution.

{% assign markenpreistest = product.metafields.custom.markenpreistest | metafield_text %}
{% assign price = product.price | money %}

{% assign result = markenpreistest | minus: price %}

The result is: {{ result }}

FDG_WEB
Shopify Expert
100 2 10

This solution is how we do complex calculations for adding custom sizes and prices.

This this example where we have a square meter (sq/m or sqm calculator) or calculate price by length calculator.

 

https://quickbar.ca/products/type-5

 

 


Tom Granger, CEO
FDG Web, Inc
Office: 360-572-0398 : Ext. 108
Cell: 425-466-0804
www.fdgweb.com

info@fdgweb.com