The request object returns information about the URL used to access your shop and the page being accessed.

request.design_mode

Whether the request comes from the theme editor.

Use request.design_mode to turn off unwanted behavior in the theme editor.

For example:

{% if request.design_mode %}
  <!-- This is only shown in the theme editor -->
{% endif %}

Do not use it to change the storefront preview shown in the theme editor. In most cases, the preview merchants see in the theme editor should match what their customers see in the live shop.

request.host

Use request.host to check which domain a customer is visiting from.

{{ request.host }}
example-shop.versacommerce.de

For example, if you have several domains, show a different greeting per domain:

{% if request.host == 'myshop.com' %}
  Welcome USA!
{% elsif request.host == 'myshop.de' %}
  Welcome Germany!
{% else %}
  Welcome!
{% endif %}

request.locale

Returns the shop_locale of the current request.

{{ request.locale.name }}
English

request.path

Returns the path of the current page.

request.path only returns the URL of an existing page. If the URL does not exist, use JavaScript to get the full URL.

{{ request.path }}
/collections/classics/products/chambray-shirt

request.page_type

Returns the type of the current page. The page types are:

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

More properties

VersaCommerce also provides these properties on the request object:

Properties Returns
origin, visual_preview_mode Request origin and visual preview flag