## TL;DR

Use a math filter on assignment: {% assign var1 = var1 | plus: 0 %} or {% assign var2 = var2 | times: 1 %}.

## Fix

1. Use a math filter on assignment: {% assign var1 = var1 | plus: 0 %} or {% assign var2 = var2 | times: 1 %}.
   Expected: you can confirm this matches your situation.

## When to use

- You are dealing with this situation.
- The symptom matches: Convert a string to an integer in Shopify Liquid.

## When NOT to use

- Unrelated issues with a different cause.
- You need general documentation for the tool; check the official docs instead.

## Compatibility

Reported per the linked source.

## Variant phrasings

### Convert a string to an integer in Shopify Liquid

## Why it happens

Stack Overflow question (score 59): converting a string variable to a number in Shopify Liquid templates.

## Edge cases

- If your error message differs even slightly, this is probably a different issue; search the exact text.
- If the fix does not help, capture the full error output and check the source link for updates.