Params - Liquid Tag Reference
On this page
The params simple tag reads URL query string or form post parameters from the current request. Use it to access user-submitted values and drive dynamic template behavior.
:::note
This tag works only inside a Liquid controller template (at controllers/<controller>/<action>.liquid), typically in the before block. It is a silent no-op outside a controller.
:::
When params runs
Use params in the before block to set values for the rest of the request:
```liquid
{% before %} {% params product_id: current_request.params.product_id %} {% params quantity: current_request.params.qty | default: 1 %} {% endbefore %} ```
The tag merges what you pass into the request’s own parameters, so the values are read back as current_request.params.product_id and current_request.params.quantity. There is no bare params object: to bind a name you can use directly in the template, use {% variables %} or {% assign %}.
Syntax
```liquid
{% params variable_name: source_value %} ```
| Property | Value |
|---|---|
| Tag Name | params |
| Type | Simple tag |
| Source | StoreConnect |
| Use in phase | before (primarily) |
Parameters
| Parameter | Description |
|---|---|
variable_name |
The key to set on the request parameters. Read back as current_request.params.variable_name |
source_value |
The value to set, usually derived from current_request.params.<key> |
| Filters optional | Use Liquid filters like default, plus: 0, and strip to transform the value |
What’s available in params
current_request.params— all query string and form POST parameters as a Map- Liquid filters —
default,plus: 0(numeric coercion),strip,downcase - Assignment context — values can be simple scalars or filtered/transformed values
A key that was never sent reads as blank rather than raising, so you can test for it directly.
Common tasks with params
1. Extract and provide a default value
```liquid
{% before %} {% assign product_id = current_request.params.id %} {% assign quantity = current_request.params.qty | default: 1 %}
{% if product_id == blank %} {% respond body: ‘{“error”: “product_id required”}’, status: 400, layout: false %} {% endif %}
{% params product_id: product_id, quantity: quantity %} {% endbefore %} ```
2. Extract and transform parameters
```liquid
{% before %} {% assign email = current_request.params.email | strip | downcase %} {% assign discount_code = current_request.params.code | upcase %}
{% action “promotion.apply”, code: discount_code %}
{% params email: email, discount_code: discount_code %} {% endbefore %} ```
3. Extract multiple parameters for cart operations
```liquid
{% before %} {% assign product_id = current_request.params.product_id %} {% assign quantity = current_request.params.qty | default: 1 | plus: 0 %} {% assign price_override = current_request.params.override_price %}
{% action “cart.add”, product_identifier: product_id, quantity: quantity, price: price_override %}
{% params product_id: product_id, quantity: quantity, price_override: price_override %} {% endbefore %} ```
Key behaviors
- Merged into the request — the value is read back as
current_request.params.variable_name, from the end of this phase onward - Filters apply during extraction —
default: 1provides a fallback if the parameter is missing - Validation recommended — always check if required parameters are blank before using them
- Multiple param tags allowed — extract as many parameters as needed in sequence
- No automatic type coercion — a parameter arrives as a string; coerce it to a number with
plus: 0
Best practices
Always validate required parameters
```liquid
{% before %} {% assign order_id = current_request.params.id %}
{% if order_id == blank %} {% redirect to: current_store.orders_path, alert: “Order ID is required” %} {% endif %}
{% params order_id: order_id %} {% endbefore %} ```
Provide sensible defaults
```liquid
{% before %} {% assign page = current_request.params.page | default: 1 | plus: 0 %} {% assign limit = current_request.params.limit | default: 20 | plus: 0 %}
{% if limit > 100 %} {% assign limit = 100 %} {% endif %}
{% params page: page, limit: limit %} {% endbefore %} ```
Use params with actions
```liquid
{% before %} {% assign cart_id = current_request.params.cart %}
{% if cart_id != blank %} {% action “cart.select”, cart_identifier: cart_id %} {% endif %}
{% params cart_id: cart_id %} {% endbefore %} ```
Relationship to variables
{% params %}— merges values into the request parameters, read back ascurrent_request.params.<name>{% variables %}— binds a name directly in the page template, used as<name>{% assign %}— an ordinary Liquid local, and the only one of the three available inside the block that sets it- Difference — params are request input carried forward; variables are rendering data
Related tags
{% variables %}— declare rendering variables after params are validated{% action %}— execute cart/commerce operations using param values{% before %}— the phase where params extraction typically happens
Was this article helpful?
Thanks for your feedback! It helps us improve our docs.