> ## Documentation Index
> Fetch the complete documentation index at: https://docs.glood.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Filters

> Reference for custom Liquid filters available in section templates

## format\_money

**Description:**\
Formats numeric values into the store's currency format based on the money\_format setting from the glood object.

**Parameters:**

* `value` (Number/String): The numeric price value to be formatted
* `money_format` (String): Override default money format
* `intl_options` (Object, optional): Currency formatting configuration
  ```js theme={null}
    {
      "en":   {
        style: 'currency',
        currency: 'USD',
        minimumFractionDigits: 2,
        maximumFractionDigits: 2
      }
    }
  ```

**Returns:**\
String - Formatted price string with currency symbol

**Example:**

```liquid theme={null}
{{ product.price | format_money: glood.shop.money_format, template.settings.intl_options }}
```

**Use Cases:**

* Formatting product prices
* Displaying compare at prices
* Showing discount amounts
* Bundle total prices

## optimize\_image

**Description:**\
Optimizes and resizes images for better performance using CDN parameters.

**Parameters:**

* `url` (String): The original image URL to be optimized
* `width` (Number, optional): Desired image width
* `height` (Number, optional): Desired image height
* `crop` (String, optional): Crop mode for the image

**Returns:**\
String - Optimized image URL with CDN parameters

**Example:**

```liquid theme={null}
{{ product.featured_image.src | optimize_image: width: 300, height: 300 }}
{{ product.image | optimize_image: width: 600, height: 600, crop: 'center' }}
```

**Use Cases:**

* Product card images
* Responsive image loading
* Thumbnail generation
* Banner image optimization

## product\_url

**Description:**\
Generates a complete product URL with tracking parameters and localization.

**Parameters:**

* `handle` (String, required): Product handle/slug
* `ref_product_id` (String, optional): Reference product ID
* `layout` (String, optional): Section layout type

**Returns:**\
String - Complete product URL with parameters

**Example:**

```liquid theme={null}
{% assign url = root_url | product_url: product.handle, glood.product.id, section.layout %}
<a href="{{ url }}">{{ product.title }}</a>
```

**Use Cases:**

* Product link generation
* Navigation building
* Tracking implementation
* Multi-language support

## product\_discount

**Description:**\
Calculates and formats product discount information based on configuration.

**Parameters:**

* `discount_config` (Object, required): Discount configuration settings
* `label_text` (String, required): Template for discount label
* `money_format` (String, required): Store's money format
* `intl_options` (Object, optional): Currency formatting configuration

**Returns:**\
String - Formatted discount text

**Example:**

```liquid theme={null}
{% assign discount = product | product_discount: section.discount_config, translations.discount_label_text, glood.shop.money_format, template.settings.intl_options %}
<span class="discount">{{ discount }}</span>
```

**Use Cases:**

* Sale badges
* Discount displays
* Price comparison
* Promotional messaging

## save\_amount

**Description:**\
Calculates and formats savings information based on discount configuration.

**Parameters:**

* `discount_config` (Object, required): Discount configuration settings
* `save_text` (String, required): Template for savings text
* `money_format` (String, required): Store's money format
* `intl_options` (Object, optional): Currency formatting configuration

**Returns:**\
String - Formatted savings text

**Example:**

```liquid theme={null}
{{ product | save_amount: section.discount_config, translations.discount_save_text, glood.shop.money_format, template.settings.intl_options }}
```

**Use Cases:**

* Savings displays
* Discount comparison
* Promotional messaging

## color\_value

**Description:**\
Retrieves color code from a color map object.

**Parameters:**

* `color_mapping` (Object, required): Color map object

**Returns:**\
String - Color code

**Example:**

```liquid theme={null}
{{ value | color_value: template.settings.color_mapping }}
```

**Use Cases:**

* Theme customization
* Product attribute mapping
* UI element styling

## to\_boolean

**Description:**\
Converts any value to a boolean.

**Parameters:**

* None

**Returns:**\
Boolean - True or False

**Example:**

```liquid theme={null}
<span data-selected="{{ selected_option.value == value | to_boolean }}">
```

**Use Cases:**

* Conditional rendering
* Boolean logic
* UI state management

## image\_dimensions

**Description:**\
Calculates responsive image dimensions based on template breakpoint settings.

**Parameters:**

* `breakpoints` (Object, required): Template breakpoint settings

**Returns:**\
Object - Object containing calculated dimensions

**Example:**

```liquid theme={null}
{{ client_info.client_width | image_dimensions: template.settings.breakpoints }}
```

**Use Cases:**

* Responsive image loading
* UI element sizing
* Image optimization

## default

**Description:**\
Provides a default value if the input is null, undefined or empty.

**Parameters:**

* `default_value` (Any, required): Value to use if input is empty

**Returns:**\
Any - Original value or default value

**Example:**

```liquid theme={null}
{{ template.settings.product_card.min_quantity | default: 1 }}
{{ translations.oos_text | default: 'Out of stock' }}
```

**Use Cases:**

* Setting default quantities
* Fallback text
* Configuration defaults
* Error prevention

## Error Handling

| Error                          | Description                                        | Solution                                                                                                                    |
| ------------------------------ | -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| Invalid Price Format           | Price value is null or not a number                | 1. Use the default filter to set a fallback value (0)<br />2. Apply money filter to format the price                        |
| Missing Image Dimensions       | Width/height not specified for image optimization  | 1. Always specify width and height parameters<br />2. Use default dimensions (300x300) if not provided                      |
| Invalid Tracking Parameters    | Missing required section context                   | 1. Check if section ID exists<br />2. Verify product handle is present<br />3. Fall back to standard product URL if missing |
| Invalid Discount Configuration | Missing money format or invalid discount structure | 1. Ensure shop money format is provided<br />2. Validate discount configuration before applying                             |

These errors require proper handling to:

* Prevent template rendering failures
* Maintain consistent price display
* Ensure proper image loading
* Keep tracking functionality intact

## Notes

* All filters are available in both section templates and CSS templates
* Some filters require specific objects from the template context
* Filter parameters marked as required must be provided for the filter to work correctly
* See [Object Definitions](/for-developers/section-template/schemas#object-definitions) for details about input objects

## Support

For help with template customization or troubleshooting, contact our support team at [support@glood.ai](mailto:support@glood.ai)
