Liquid Template Variables - request

From Spiffy Stores Knowledge Base

The Liquid template variable request has the following attributes:

request.parameter

You can access any request parameter by name.

For example, a URL can include a parameter:

http://storedemo.spiffystores.com/?theme=blue

This theme parameter can be accessed by

request.theme

request.host

Returns the host name portion of the URL request.

For example, if we go to http://storedemo.spiffystores.com, then the request.host returns:

storedemo.spiffystores.com

request.url

Returns the complete URL used for this request.

For example, if we go to http://storedemo.spiffystores.com/products/widget, then the request.url returns:

http://storedemo.spiffystores.com/products/widget

request.referer

Returns the referer URL for this request.

For example, if we came to the current page from http://storedemo.spiffystores.com/collections/widgets, then the request.referer returns:

http://storedemo.spiffystores.com/collections/widgets

request.remote_ip

Returns the IP address of the user accessing the page.

request.country

Returns the Country name of the user accessing the page. This information is determined from the IP address, and may not be accurate in all cases. Typically, the results are 99.5% accurate.

The name returned is the ISO Printable name. For example:

Australia

request.country_code

Returns the two character ISO Country Code of the user accessing the page. This information is determined from the IP address, and may not be accurate in all cases. Typically, the results are 99.5% accurate.

The code returned is the ISO Code. For example:

AU

request.province

Returns the Province/State name of the user accessing the page. This information is determined from the IP address, and may not be accurate in all cases. Typically, the results are 99.5% accurate.

The name returned is the ISO Printable name. For example:

New South Wales

request.province_code

Returns the two character ISO Province/State Code of the user accessing the page. This information is determined from the IP address, and may not be accurate in all cases. Typically, the results are 99.5% accurate.

The code returned is the ISO Code. For example:

NSW

request.city

Returns the City name of the user accessing the page. This information is determined from the IP address, and may not be accurate in all cases. Typically, the results are 79% accurate. For example:

Sydney

request.timezone

Returns the Time Zone of the user accessing the page. This information is determined from the IP address, and may not be accurate in all cases. For example, if the user is using a proxy, then the time zone of the proxy server will be returned, rather than that of the user.

The name returned is the standard timezone name. For example:

Australia/Sydney

request.utc_offset

JavaScript code is inserted in every page to detect the UTC offset on a user's computer. This value, in seconds, is set as a cookie, which can be retrieved and returned here.

This value gives an accurate reading of the user's time zone and will probably be more accurate than request.timezone.

No value is available when the initial page is displayed, as the JavaScript to calculate the time zone offset has not had a chance to run.

request.client_time

Returns the best available guess for the current time on the user's computer. If the request.utc_offset value is available, then this is used to calculate the time zone. If this value is not available, then the time zone that has been derived from the IP address is used, and failing that, the local time for the store is used.

request.currency

Returns the local currency of the user, based upon the Country from which the client has accessed the page. This information is determined from the IP address, and may not be accurate in all cases.

AUD

request.user_agent

Returns the user agent string of the user's browser. Each browser returns a unique user agent string, which provides information about the version and features that the browser provides.

Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0 

request.browser

Returns the name of the user's browser.

Firefox

request.browser_version

Returns the version of the user's browser.

25.0

request.browser_platform

Returns the platform of the user's browser. This will be the generic type of operating system that the user is running, such as Windows or Macintosh.

Windows

request.browser_os

Returns the operating system that the user's browser is running under.

Windows 7

request.mobile?

Returns true if the user's browser is running on a mobile device.

request.tablet?

Returns true if the user's browser is running on a tablet device.

request.bot?

Returns true if the request appears to be coming from a robot or web crawler.

request.ajax?

Returns true if the request is using Ajax to render part of the page.

request.locale

Returns the shop_locale of the current request.

request.page_type

Returns the type of the current page. These are the different page types:

  • 404
  • article
  • blog
  • cart
  • collection
  • list-collections
  • customers/account
  • customers/activate_account
  • customers/addresses
  • customers/login
  • customers/order
  • customers/register
  • customers/reset_password
  • index
  • page
  • password
  • product
  • search

Further Reference