Difference between revisions of "Liquid Template Variables - shop"

From Spiffy Stores Knowledge Base

 
(31 intermediate revisions by the same user not shown)
Line 1: Line 1:
The liquid template variable ''shop'' has the following attributes:
+
The Liquid template variable '''shop''' has the following attributes:
  
 
== <code>shop.id</code> ==
 
== <code>shop.id</code> ==
  
Returns the unique internal shop id number.
+
Returns the unique internal store id number.
  
 
This is normally only for internal usage.
 
This is normally only for internal usage.
  
 
== <code>shop.name</code> ==
 
== <code>shop.name</code> ==
 +
Returns a string with the store's name.
  
Returns a string with the shop's name.
+
Example usage:
 +
 
 +
<pre>{{ shop.name }}</pre>
 +
== <code>shop.email</code> ==
 +
Returns the store's email address.
  
 
Example usage:
 
Example usage:
  
<pre>{{ shop.name }}</pre>
+
<pre>{{ shop.email }}</pre>
 +
 
 +
== <code>shop.description</code> ==
 +
 
 +
Returns a string with the store's description. This value can be configured on the "General Settings" page, under the "Preferences" tab.
 +
 
 +
If your theme includes the standard headers as follows, then this description will automatically appear in the header tags of your home page.
 +
 
 +
<pre>{% include 'headers' %}</pre>
 +
 
 +
You may use this variable to build a meta description tag for your home page manually if you prefer.
 +
 
 +
Example usage:
 +
 
 +
<pre>{% if template == 'index' and shop.description != '' %}
 +
<meta name="description" content="{{ shop.description }}" />
 +
{% endif %}
 +
</pre>
 +
 
 +
== <code>shop.owner</code> ==
 +
 
 +
Returns a string with the name of the store's owner.
 +
 
 +
Example usage:
 +
 
 +
<pre>Dear {{ shop.owner }}, you have received a new order!</pre>
  
 
== <code>shop.currency</code> ==
 
== <code>shop.currency</code> ==
  
Returns a string with the name of the currency that this shop uses. This is usually a three character representation (e.g. AUD).
+
Returns a string with the name of the currency that this store uses. This is usually a three character representation (e.g. AUD).
  
 
Example usage:
 
Example usage:
  
 
<pre>All prices are in {{ shop.currency }}</pre>
 
<pre>All prices are in {{ shop.currency }}</pre>
 +
 +
== <code>shop.currency_name</code> ==
 +
 +
Returns a string containing the full descriptive name of the store's currency.
 +
 +
For example
 +
 +
<pre>Australian Dollar (AUD)</pre>
  
 
== <code>shop.country</code> ==
 
== <code>shop.country</code> ==
  
Returns the printable name of the country in which the shop is located.
+
Returns the printable name of the country in which the store is located.
  
<pre>This shop is located in {{ shop.country }}</pre>
+
<pre>This store is located in {{ shop.country }}</pre>
  
 
== <code>shop.country_iso</code> ==
 
== <code>shop.country_iso</code> ==
  
Returns the two character ISO country code for the shop.
+
Returns the two character ISO country code for the store.
  
<pre>{% if shop.country_iso == 'AU' %}GST is applicable to this shop{% endif %}</pre>
+
<pre>{% if shop.country_iso == 'AU' %}GST is applicable to this store{% endif %}</pre>
  
 
== <code>shop.tax_number</code> ==
 
== <code>shop.tax_number</code> ==
  
Returns the taxation number for the shop, if required by local legislation. This is usually an ABN (Australia), GST Number (New Zealand) or VAT Registration (Europe).
+
Returns the taxation number for the store, if required by local legislation.  
 +
 
 +
This is usually an ABN (Australia), GST Number (New Zealand) or VAT Registration (Europe).
  
 
<pre>TAX INVOICE {{ shop.tax_number }}</pre>
 
<pre>TAX INVOICE {{ shop.tax_number }}</pre>
Line 43: Line 83:
 
== <code>shop.url</code> ==
 
== <code>shop.url</code> ==
  
Returns the full URL for your shop.
+
Returns the full URL for your store.
  
 
Note: The value depends upon the primary address configured under '''Preferences -> DNS & Domains'''.
 
Note: The value depends upon the primary address configured under '''Preferences -> DNS & Domains'''.
Line 49: Line 89:
 
== <code>shop.domain</code> ==
 
== <code>shop.domain</code> ==
  
Returns the domain of your shop.
+
Returns the domain of your store.
  
 
Note: The value depends upon the primary address configured under '''Preferences -> DNS & Domains'''.
 
Note: The value depends upon the primary address configured under '''Preferences -> DNS & Domains'''.
 +
 +
== <code>shop.permanent_domain</code> ==
 +
 +
Returns the ''.spiffystores.com'' domain name of your store.
  
 
== <code>shop.products</code> ==
 
== <code>shop.products</code> ==
  
Returns all the products in the shop.
+
Returns all the products in the store.
  
 
== <code>shop.products_count</code> ==
 
== <code>shop.products_count</code> ==
  
Returns the number of products in the shop.
+
Returns the number of products in the store.
  
 
Example usage:
 
Example usage:
  
<pre>{{ shop.products_count }} {{ shop.products_count | pluralize: 'product', 'products' }} are available</pre>
+
<pre>
 +
{{ shop.products_count }} {{ shop.products_count | pluralize: 'product', 'products' }} are available
 +
</pre>
  
 
== <code>shop.collections</code> ==
 
== <code>shop.collections</code> ==
  
Returns all the collections in the shop.
+
Returns all the collections in the store.
  
 
== <code>shop.collections_count</code> ==
 
== <code>shop.collections_count</code> ==
  
Returns the number of collections in the shop.
+
Returns the number of collections in the store.
 +
 
 +
== <code>shop.all_collections</code> ==
 +
 
 +
Returns all of the store's collections without pagination.
 +
 
 +
== <code>shop.money_with_currency_format</code> ==
 +
 
 +
Return the currency formatting string which includes the currency symbol.
 +
 
 +
== <code>shop.money_format</code> ==
 +
 
 +
Return the currency formatting string excluding the currency symbol.
 +
 
 +
== <code>shop.currency_codes</code> ==
 +
 
 +
Return an array of currency codes that are supported for this store.
 +
 
 +
The currency codes are determined by the list of countries that have been added in the "Preferences -> Regions & taxes" section of your Toolbox.
 +
 
 +
<pre>
 +
  <select>
 +
    {% for c in shop.currency_codes %}
 +
    <option value="{{ c }}"{% if currency == c %} selected="selected"{% endif %}>{{ c }}</option>
 +
    {% endfor %}
 +
  </select>
 +
</pre>
 +
 
 +
== <code>shop.currency_options</code> ==
 +
 
 +
Returns a pre-formatted set of HTML option tags, including the full name of the currency, which can be used within select tags.
 +
 
 +
The currency codes are determined by the list of countries that have been added in the "Preferences -> Regions & taxes" section of your Toolbox.
 +
 
 +
Here is an example of the options that are returned:
 +
 
 +
<pre>
 +
  <option value="AUD">Australian Dollar (AUD)</option>
 +
  <option value="NZD">New Zealand Dollar (NZD)</option>
 +
  <option value="USD">United States Dollar (USD)</option>
 +
  <option value="EUR" selected="selected">Euro (EUR)</option>
 +
  <option value="GBP">British Pound (GBP)</option>
 +
  <option value="CAD">Canadian Dollar (CAD)</option>
 +
</pre>
 +
 
 +
These options can be used as follows:
 +
 
 +
<pre>
 +
  <select>
 +
    {{ shop.currency_options }}
 +
  </select>
 +
</pre>
 +
 
 +
== <code>shop.types</code> ==
 +
 
 +
Returns a list of all unique product types in the store. An array of [[ Liquid Template Variables - type | type]]s is returned.
 +
 
 +
Example usage:
 +
 
 +
<pre>
 +
<ul>
 +
{% for product_type in shop.types %}
 +
  <li>
 +
    {{ product_type | link_to_type }}
 +
  </li>
 +
{% endfor %}
 +
</ul>
 +
</pre>
 +
 
 +
== <code>shop.vendors</code> ==
 +
 
 +
Returns a list of all unique product vendors in the store. An array of [[ Liquid Template Variables - vendor | vendor]]s is returned.
 +
 
 +
Example usage:
 +
 
 +
<pre>
 +
<ul>
 +
{% for product_vendor in shop.vendors %}
 +
  <li>
 +
    {{ product_vendor | link_to_vendor }}
 +
  </li>
 +
{% endfor %}
 +
</ul>
 +
</pre>
 +
 
 +
== <code>shop.enabled_payment_types</code> ==
 +
 
 +
Returns an array of credit card names that are currently enabled for the store. Use the '''payment_type_img_url''' filter to return a link to the SVG image file for the credit card.
 +
 
 +
The possible values for this array are -
 +
 
 +
* visa
 +
* master
 +
* american_express
 +
* paypal
 +
* afterpay
 +
* jcb
 +
* diners_club
 +
* maestro
 +
* discover
 +
* solo
 +
* switch
 +
* laser
 +
* dankort
 +
* forbrugsforeningen
 +
* dwolla
 +
 
 +
<pre>
 +
{% for type in shop.enabled_payment_types %}
 +
  <img src="{{ type | payment_type_img_url }}" width="80" />
 +
{% endfor %}
 +
</pre>
 +
 
 +
== <code>shop.customer_accounts_enabled</code> ==
 +
 
 +
Return true if customer accounts have been enabled in this store.
 +
 
 +
<pre>
 +
{% if shop.customer_accounts_enabled %}
 +
  <li>
 +
  {% if customer %}
 +
    <a href="/account">Your Account</a>
 +
  {% else %}
 +
    {{ 'Log in' | customer_login_link }}
 +
    {% if shop.customer_accounts_optional %}
 +
    <span class="or">or</span>
 +
    {{ 'Create an account' | customer_register_link }}
 +
    {% endif %}
 +
  {% endif %}
 +
  </li>
 +
{% endif %}
 +
</pre>
 +
 
 +
== <code>shop.customer_accounts_optional</code> ==
 +
 
 +
Return true if customer accounts are enabled and are optional in this store.
 +
 
 +
See previous example for usage.
 +
 
 +
== <code>shop.metafields</code> ==
 +
Return the [[Liquid Template Variables - metafields|metafields]] for the shop.
 +
 
 +
Metafields can only be managed using the Spiffy Stores API.
 +
== <code>shop.published_locales</code> ==
 +
Returns an array of shop_locale objects. Each object represents a shop locale that's published on the shop.
 +
 
 +
<pre>
 +
{% for locale in shop.published_locales %}
 +
  {{ locale.name }} ({{ locale.iso_code }})
 +
{% endfor %}
 +
</pre>
 +
== <code>shop.primary_locale</code> ==
 +
Returns the primary shop_locale object.
 +
== <code>shop.locale</code> ==
 +
Returns the shop's primary locale iso code.
  
== <code>shop.all_collections</code>==
+
== Further Reference ==
  
Returns all of the shop's collections without pagination.
+
* [[Liquid Basics]]
 +
* [[Liquid Tag Reference]]
 +
* [[Liquid Filter Reference]]
 +
* [[Liquid Variable Reference]]
 +
* [[Liquid Paginate Tag|Pagination ]]

Latest revision as of 18:29, 12 March 2021

The Liquid template variable shop has the following attributes:

shop.id

Returns the unique internal store id number.

This is normally only for internal usage.

shop.name

Returns a string with the store's name.

Example usage:

{{ shop.name }}

shop.email

Returns the store's email address.

Example usage:

{{ shop.email }}

shop.description

Returns a string with the store's description. This value can be configured on the "General Settings" page, under the "Preferences" tab.

If your theme includes the standard headers as follows, then this description will automatically appear in the header tags of your home page.

{% include 'headers' %}

You may use this variable to build a meta description tag for your home page manually if you prefer.

Example usage:

{% if template == 'index' and shop.description != '' %}
<meta name="description" content="{{ shop.description }}" />
{% endif %}

shop.owner

Returns a string with the name of the store's owner.

Example usage:

Dear {{ shop.owner }}, you have received a new order!

shop.currency

Returns a string with the name of the currency that this store uses. This is usually a three character representation (e.g. AUD).

Example usage:

All prices are in {{ shop.currency }}

shop.currency_name

Returns a string containing the full descriptive name of the store's currency.

For example

Australian Dollar (AUD)

shop.country

Returns the printable name of the country in which the store is located.

This store is located in {{ shop.country }}

shop.country_iso

Returns the two character ISO country code for the store.

{% if shop.country_iso == 'AU' %}GST is applicable to this store{% endif %}

shop.tax_number

Returns the taxation number for the store, if required by local legislation.

This is usually an ABN (Australia), GST Number (New Zealand) or VAT Registration (Europe).

TAX INVOICE {{ shop.tax_number }}

shop.url

Returns the full URL for your store.

Note: The value depends upon the primary address configured under Preferences -> DNS & Domains.

shop.domain

Returns the domain of your store.

Note: The value depends upon the primary address configured under Preferences -> DNS & Domains.

shop.permanent_domain

Returns the .spiffystores.com domain name of your store.

shop.products

Returns all the products in the store.

shop.products_count

Returns the number of products in the store.

Example usage:

{{ shop.products_count }} {{ shop.products_count | pluralize: 'product', 'products' }} are available

shop.collections

Returns all the collections in the store.

shop.collections_count

Returns the number of collections in the store.

shop.all_collections

Returns all of the store's collections without pagination.

shop.money_with_currency_format

Return the currency formatting string which includes the currency symbol.

shop.money_format

Return the currency formatting string excluding the currency symbol.

shop.currency_codes

Return an array of currency codes that are supported for this store.

The currency codes are determined by the list of countries that have been added in the "Preferences -> Regions & taxes" section of your Toolbox.

  <select>
    {% for c in shop.currency_codes %}
    <option value="{{ c }}"{% if currency == c %} selected="selected"{% endif %}>{{ c }}</option>
    {% endfor %}
  </select>

shop.currency_options

Returns a pre-formatted set of HTML option tags, including the full name of the currency, which can be used within select tags.

The currency codes are determined by the list of countries that have been added in the "Preferences -> Regions & taxes" section of your Toolbox.

Here is an example of the options that are returned:

  <option value="AUD">Australian Dollar (AUD)</option>
  <option value="NZD">New Zealand Dollar (NZD)</option>
  <option value="USD">United States Dollar (USD)</option>
  <option value="EUR" selected="selected">Euro (EUR)</option>
  <option value="GBP">British Pound (GBP)</option>
  <option value="CAD">Canadian Dollar (CAD)</option>

These options can be used as follows:

  <select>
    {{ shop.currency_options }}
  </select>

shop.types

Returns a list of all unique product types in the store. An array of types is returned.

Example usage:

<ul>
{% for product_type in shop.types %}
  <li>
    {{ product_type | link_to_type }}
  </li>
{% endfor %}
</ul>

shop.vendors

Returns a list of all unique product vendors in the store. An array of vendors is returned.

Example usage:

<ul>
{% for product_vendor in shop.vendors %}
  <li>
    {{ product_vendor | link_to_vendor }}
  </li>
{% endfor %}
</ul>

shop.enabled_payment_types

Returns an array of credit card names that are currently enabled for the store. Use the payment_type_img_url filter to return a link to the SVG image file for the credit card.

The possible values for this array are -

  • visa
  • master
  • american_express
  • paypal
  • afterpay
  • jcb
  • diners_club
  • maestro
  • discover
  • solo
  • switch
  • laser
  • dankort
  • forbrugsforeningen
  • dwolla
{% for type in shop.enabled_payment_types %}
  <img src="{{ type | payment_type_img_url }}" width="80" />
{% endfor %}

shop.customer_accounts_enabled

Return true if customer accounts have been enabled in this store.

{% if shop.customer_accounts_enabled %}
  <li>
  {% if customer %}
    <a href="/account">Your Account</a>
  {% else %}
    {{ 'Log in' | customer_login_link }}
    {% if shop.customer_accounts_optional %}
    <span class="or">or</span>
    {{ 'Create an account' | customer_register_link }}
    {% endif %}
  {% endif %}
  </li>
{% endif %}

shop.customer_accounts_optional

Return true if customer accounts are enabled and are optional in this store.

See previous example for usage.

shop.metafields

Return the metafields for the shop.

Metafields can only be managed using the Spiffy Stores API.

shop.published_locales

Returns an array of shop_locale objects. Each object represents a shop locale that's published on the shop.

{% for locale in shop.published_locales %}
  {{ locale.name }} ({{ locale.iso_code }})
{% endfor %}

shop.primary_locale

Returns the primary shop_locale object.

shop.locale

Returns the shop's primary locale iso code.

Further Reference