Skip to main content
Skip table of contents

Display Pattern: Number

Summary

Calculate the discounted product price based on a number field for product price and another number field for discount percentage.

CODE
{% assign discount = data.corporateInformation.discountPercentage | divided_by: 100 %}
{% assign discountValue = data.corporateInformation.productPrice | times: discount %}
{% assign discountPrice = data.corporateInformation.productPrice | minus: discountValue %}

{% if data.data.corporateInformation.discountPercentage %}
Discount Price: {{ discountPrice }}
{% endif %} 

Setup in Picturepark

  • Layer: Corporate Information

  • Field: Product Price

  • Field: Discount Percentage

Field Value Access

data.corporateInformation.productPrice

Use Case

A valid use case could be to calculate the discount price, either working with a fixed discount or another number field carrying the discount (ID: discountPercentage), shown in this example:  

JSON
{% assign discount = data.corporateInformation.discountPercentage | divided_by: 100 %}
{% assign discountValue = data.corporateInformation.productPrice | times: discount %}
{% assign discountPrice = data.corporateInformation.productPrice | minus: discountValue %}

{% if data.data.corporateInformation.discountPercentage %}
Discount Price: {{ discountPrice }}
{% endif %} 


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.