finite - Liquid Filter Reference
On this page
Description
Replaces a non-finite number (Infinity, -Infinity, or NaN) with a replacement value, so a feed emitting JSON, CSV, or XML gets a valid number. A finite number, or a value that is not a number, is returned unchanged.
The usual case is a product’s total_available_to_sell when there is no limit on what it can sell: stock is not tracked, or the product is backorderable, and no maximum quantity is set. That value is infinite, and it otherwise renders as null in JSON but as the literal text Infinity in CSV.
| Property | Value |
|---|---|
| Return Type | number |
| Category | numbers |
Options
| Option | Description |
|---|---|
replacement |
The value to use for a non-finite number. The default is 2147483647, a large integer that stands for “unlimited”. |
Examples
```liquid
{{ 42 | finite }} ```
Output: 42
```liquid
{{ product.total_available_to_sell | finite }} ```
Output: 2147483647 when the product has no limit on what it can sell, otherwise the quantity.
```liquid
{{ product.total_available_to_sell | finite, replacement: 0 }} ```
Output: 0 when the product has no limit on what it can sell, otherwise the quantity.
When you build a feed row with set_key, assign the result first. A filter at the end of a set_key chain applies to the whole map, not to the value:
```liquid
{%- assign inventory = product.total_available_to_sell | finite -%} {%- assign row = row | set_key: “inventory”, inventory -%} ```
Was this article helpful?
Thanks for your feedback! It helps us improve our docs.