Difference between revisions of "Liquid Template Variables - request"
From Spiffy Stores Knowledge Base
m (→request.ajax?) |
m |
||
Line 1: | Line 1: | ||
The Liquid template variable '''request''' has the following attributes: | The Liquid template variable '''request''' has the following attributes: | ||
− | |||
== <code>request.''parameter''</code> == | == <code>request.''parameter''</code> == | ||
− | |||
You can access any request parameter by name. | You can access any request parameter by name. | ||
Line 12: | Line 10: | ||
<pre>request.theme</pre> | <pre>request.theme</pre> | ||
− | |||
== <code>request.host</code> == | == <code>request.host</code> == | ||
− | |||
Returns the host name portion of the URL request. | Returns the host name portion of the URL request. | ||
Line 20: | Line 16: | ||
<pre>storedemo.spiffystores.com</pre> | <pre>storedemo.spiffystores.com</pre> | ||
− | |||
== <code>request.url</code> == | == <code>request.url</code> == | ||
− | |||
Returns the complete URL used for this request. | Returns the complete URL used for this request. | ||
Line 28: | Line 22: | ||
<pre>http://storedemo.spiffystores.com/products/widget</pre> | <pre>http://storedemo.spiffystores.com/products/widget</pre> | ||
− | |||
== <code>request.referer</code> == | == <code>request.referer</code> == | ||
− | |||
Returns the referer URL for this request. | Returns the referer URL for this request. | ||
Line 36: | Line 28: | ||
<pre>http://storedemo.spiffystores.com/collections/widgets</pre> | <pre>http://storedemo.spiffystores.com/collections/widgets</pre> | ||
− | |||
== <code>request.remote_ip</code> == | == <code>request.remote_ip</code> == | ||
− | |||
Returns the IP address of the user accessing the page. | Returns the IP address of the user accessing the page. | ||
− | |||
== <code>request.country</code> == | == <code>request.country</code> == | ||
− | |||
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. | 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. | ||
Line 50: | Line 38: | ||
Australia | Australia | ||
</pre> | </pre> | ||
− | |||
== <code>request.country_code</code> == | == <code>request.country_code</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. | 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. | ||
Line 60: | Line 46: | ||
AU | AU | ||
</pre> | </pre> | ||
− | |||
== <code>request.province</code> == | == <code>request.province</code> == | ||
− | |||
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. | 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. | ||
Line 70: | Line 54: | ||
New South Wales | New South Wales | ||
</pre> | </pre> | ||
− | |||
== <code>request.province_code</code> == | == <code>request.province_code</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. | 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. | ||
Line 80: | Line 62: | ||
NSW | NSW | ||
</pre> | </pre> | ||
− | |||
== <code>request.city</code> == | == <code>request.city</code> == | ||
− | |||
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: | 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: | ||
Line 88: | Line 68: | ||
Sydney | Sydney | ||
</pre> | </pre> | ||
− | |||
== <code>request.timezone</code> == | == <code>request.timezone</code> == | ||
− | |||
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. | 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. | ||
Line 98: | Line 76: | ||
Australia/Sydney | Australia/Sydney | ||
</pre> | </pre> | ||
− | |||
== <code>request.utc_offset</code> == | == <code>request.utc_offset</code> == | ||
− | |||
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. | 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. | ||
Line 106: | Line 82: | ||
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. | 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. | ||
− | |||
== <code>request.client_time</code> == | == <code>request.client_time</code> == | ||
− | |||
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. | 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. | ||
− | |||
== <code>request.currency</code> == | == <code>request.currency</code> == | ||
− | |||
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. | 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. | ||
Line 118: | Line 90: | ||
AUD | AUD | ||
</pre> | </pre> | ||
− | |||
== <code>request.user_agent</code> == | == <code>request.user_agent</code> == | ||
− | |||
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. | 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. | ||
Line 126: | Line 96: | ||
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0 | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0 | ||
</pre> | </pre> | ||
− | |||
== <code>request.browser</code> == | == <code>request.browser</code> == | ||
− | |||
Returns the name of the user's browser. | Returns the name of the user's browser. | ||
Line 134: | Line 102: | ||
Firefox | Firefox | ||
</pre> | </pre> | ||
− | |||
== <code>request.browser_version</code> == | == <code>request.browser_version</code> == | ||
− | |||
Returns the version of the user's browser. | Returns the version of the user's browser. | ||
Line 142: | Line 108: | ||
25.0 | 25.0 | ||
</pre> | </pre> | ||
− | |||
== <code>request.browser_platform</code> == | == <code>request.browser_platform</code> == | ||
− | |||
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. | 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. | ||
Line 150: | Line 114: | ||
Windows | Windows | ||
</pre> | </pre> | ||
− | |||
== <code>request.browser_os</code> == | == <code>request.browser_os</code> == | ||
− | |||
Returns the operating system that the user's browser is running under. | Returns the operating system that the user's browser is running under. | ||
Line 158: | Line 120: | ||
Windows 7 | Windows 7 | ||
</pre> | </pre> | ||
− | |||
== <code>request.mobile?</code> == | == <code>request.mobile?</code> == | ||
− | |||
Returns true if the user's browser is running on a mobile device. | Returns true if the user's browser is running on a mobile device. | ||
− | |||
== <code>request.bot?</code> == | == <code>request.bot?</code> == | ||
− | |||
Returns true if the request appears to be coming from a robot or web crawler. | Returns true if the request appears to be coming from a robot or web crawler. | ||
− | |||
== <code>request.ajax?</code> == | == <code>request.ajax?</code> == | ||
Returns true if the request is using Ajax to render part of the page. | Returns true if the request is using Ajax to render part of the page. | ||
== <code>request.locale</code> == | == <code>request.locale</code> == | ||
Returns the shop_locale of the current request. | Returns the shop_locale of the current request. | ||
+ | == <code>request.page_type</code> == | ||
+ | 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 == | == Further Reference == | ||
Revision as of 12:31, 27 October 2020
The Liquid template variable request has the following attributes:
Contents
- 1 request.parameter
- 2 request.host
- 3 request.url
- 4 request.referer
- 5 request.remote_ip
- 6 request.country
- 7 request.country_code
- 8 request.province
- 9 request.province_code
- 10 request.city
- 11 request.timezone
- 12 request.utc_offset
- 13 request.client_time
- 14 request.currency
- 15 request.user_agent
- 16 request.browser
- 17 request.browser_version
- 18 request.browser_platform
- 19 request.browser_os
- 20 request.mobile?
- 21 request.bot?
- 22 request.ajax?
- 23 request.locale
- 24 request.page_type
- 25 Further Reference
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.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