Request - Liquid Object Reference

This article requires advanced skills to implement.
Liquid

Description

The Request object contains information about the web request.

Attributes

Attribute Type Description
base_url String Returns the store base url including the store path if present e.g. 'https://store.example.com/au'
canonical_path String Returns the canonical path for the current request
canonical_url String Returns the canonical URL for the current request
content_type String Returns the content type for the current request e.g. '/page.txt' returns 'text/plain'
fullpath String Returns the full path for the current request including the query string e.g. '/my-path?page=1' and includes the store's path if present, such as '/au/my-path?page=1'
geolocation_city String Returns the city detected from the request IP address
geolocation_country String Returns the country name detected from the request IP address
geolocation_country_code String Returns the two-letter country code detected from the request IP address
geolocation_latitude Number Returns the latitude coordinate detected from the request IP address
geolocation_longitude Number Returns the longitude coordinate detected from the request IP address
geolocation_region String Returns the region/state detected from the request IP address
host String Returns the hostname used for this request e.g. 'store.example.com'
ip String Returns the IP address of the request
local_path String Returns the path for the current request without the store, i.e., everything after the host name plus store path e.g. '/au/my-path' returns '/my-path'
page_number Number Returns the page number from the query string. Note the query parameter is configurable, and there could be multiple on a page. The first one used is returned.
params Map Returns a Map of query string parameters for the current request
path String Returns the path for the current request, i.e. everything after the host name e.g. '/my-path' and includes the store's path if present, such as '/au/my-path'
protocol String Returns the protocol of the request, 'http://' or 'https://'
query_string String Returns the query string part of the URL, i.e., everything after '?' e.g. 'page=1'
store_path String Returns the store path if present e.g. '/au', 'store_path' plus 'relative_path' returns the same output as 'path'
url String Returns the entire URL used for the request, e.g. https://store.example.com/au/my-path?page=1
valid_geolocation? Boolean Returns true if geolocation lookup was successful