AVADA logo
Published on

How to show absolute value of a number in Shopify

343 words2 min read
  • Name

Since 2006, Liquid has been used in Shopify as a language template. In Liquid, you use tags consisting of comment, control flow, iteration, raw, and variable to show complex content. In today tutorial, we will tell you about math filters, especially abs value so that you are able to display math formulas.

Table of content

General information about Liquid {#general-information-about-liquid}

Liquid is the backbone language of Shopify and has been trusted by a lot of web developers. Liquid is one of the Shopify's open-source template languages. The template has been sold since 2006 and now become a good source for a lot of hosted website application such as Jekyll, salesforce desk, and zendesk.

What is math filter {#what-is-math-filter}

Math filters let you apply mathematical tasks. Math filters can be linked, and like other filters in Liquid, the computer will read math filter from left to right. In the example below, the computer will access minus then times and finally divided by.

You save {{ product.compare_at_price | minus: product.price | times: 100.0 | divided_by: product.compare_at_price }}%

How to show absolute value of a number {#how-to-show-absolute-value-of-a-number}

Math filters contain a lot of types, and this tutorial focuses on abs. Abs returns the absolute value of a number. You have already known about the absolute number when studying about math in high school, right? For instance, abs will generate a positive number.


{{ -17 | abs }}



In addition, abs also work on a string if the string only contains a number.


{{ "-19.86" | abs }}




To sum up, math filters help to apply mathematics formulas on your website. Abs is a value that produces positive number which is familiar with absolute number that you have known in your high school. We hope that you find this useful and let us know about your difficulties.

Exclusive Offer: Shopify Deal for PageFly Audience

Start Your Online Business with Shopify 12 Day Free Trial + Pay Only 1$ For Your First Month