# Operators

Operators in Liquid are essential for comparing and combining variables in theme templates. They enable theme developers to create logic and conditional statements. This document provides an overview of the available operators in Liquid and their usage.

## 1. Arithmetic Operators

Arithmetic operators perform mathematical operations between two values or variables.

### 1.1. Addition (+)

Adds two values.

Example:

```
{{ product.price + additional_price }}
```

### 1.2. Subtraction (-)

Subtracts one value from another.

Example:

```liquid
{{ product.price - discount }}
```

### 1.3. Multiplication (\*)

Multiplies two values.

Example:

```
{{ product.price * quantity }}
```

### 1.4. Division (/)

Divides one value by another.

Example:

```
{{ product.price / installments }}
```

### 1.5. Modulo (%)

Returns the remainder of a division operation.

Example:

```
{{ product.reviews_count % 10 }}
```

## 2. Comparison Operators

Comparison operators are used to compare two values or variables.

### 2.1. Equal (==)

Returns true if the values on both sides of the operator are equal.

Example:

```makefile
{% if product.price == 0 %}
  Free
{% endif %}
```

### 2.2. Not Equal (!=)

Returns true if the values on both sides of the operator are not equal.

Example:

```makefile
{% if product.price != 0 %}
  Paid
{% endif %}
```

### 2.3. Greater Than (>)

Returns true if the value on the left is greater than the value on the right.

Example:

```makefile
{% if product.inventory_quantity > 0 %}
  In stock
{% endif %}
```

### 2.4. Less Than (<)

Returns true if the value on the left is less than the value on the right.

Example:

```makefile
{% if product.inventory_quantity < 10 %}
  Low stock
{% endif %}
```

### 2.5. Greater Than or Equal To (>=)

Returns true if the value on the left is greater than or equal to the value on the right.

Example:

```makefile
{% if product.rating >= 4 %}
  Highly rated
{% endif %}
```

### 2.6. Less Than or Equal To (<=)

Returns true if the value on the left is less than or equal to the value on the right.

Example:

```makefile
{% if product.rating <= 2 %}
  Poorly rated
{% endif %}
```

## 3. Logical Operators

Logical operators are used to combine multiple conditions.

### 3.1. AND (and)

Returns true if both conditions are true.

Example:

```arduino
{% if product.available and product.featured %}
  Featured and available
{% endif %}
```

### 3.2. OR (or)

Returns true if at least one of the conditions is true.

Example:

```graphql
{% if product.on_sale or product.clearance %}
  On sale or clearance
{% endif %}
```

## Summary

Understanding and using operators in Liquid is crucial for creating dynamic, responsive, and flexible theme templates. By using arithmetic, comparison, and logical operators, you can build complex logic and conditional statements to tailor your theme's appearance and behavior to specific scenarios.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cryptococo.gitbook.io/cocoshop-theme-development/liquid/basics/operators.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
