Difference between revisions of "Shopify Liquid"

From the Directed Edge Developer Base
Jump to: navigation, search
(Created page with "__TOC__ == Liquid Variables supported by Directed Edge == Following Liquid Variables are supported in custom templates: * groups - An array of recommendation types with following...")
 
 
(21 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__TOC__
+
See also our page with [[Shopify Liquid Examples]].
== Liquid Variables supported by Directed Edge ==
+
 
Following Liquid Variables are supported in custom templates:
+
== Liquid variables supported by Directed Edge ==
* groups - An array of recommendation types with following variables
+
=== <tt>groups</tt> ===
** handle - A machine friendly identifier for the group (e.g. bundle, recommended_product, etc.)
+
The liquid variable groups contain all recommendation types that are available for the requested page. Each group has following properties:
** label - A rendered label text (according to your settings)
+
{| class="variable-ref-table"
** bundle - A boolean field that indicates if this group is a bundle
+
|-
** products - An array of [http://docs.shopify.com/themes/liquid-variables/product Products]
+
| label || A formatted label of the group, for example, “Recommended Items”, “Recently Viewed”, etc. Those labels can be customized in our [http://shopify.directededge.com/settings#styling Appearance Settings].
* bundle
+
|-
** text - Bundle's buy message (e.g. 'Buy both for 20$')
+
| handle || A machine friendly identifier for the group (e.g. <tt>bundle</tt>, <tt>recommended_product</tt>, etc.)
** price - The sum of a bundles price
+
|-
** buy_link - A link that will add a bundle's products into the cart
+
| products || An array of all of the products in returned for this recommendations group.
 +
The following example would print title and price of all products in all available groups:
 +
<source lang="xml">
 +
{% for group in groups %}
 +
  <ul>
 +
  {% for product in group.products %}
 +
    <li>
 +
    <b>{{ product.title }}</b><br />
 +
    {{ product.price | money }}
 +
  {% endfor %}
 +
  </ul>
 +
{% endfor %}
 +
</source>
 +
A detailed description of all product’s properties can be found [http://docs.shopify.com/themes/liquid-variables/product here].
 +
|-
 +
| bundle || A boolean field that indicates if this group is a bundle. This is useful to render custom content for that particular group. The following snippet would display both product images separated by a plus sign and followed by a equals sign and the bundle price:
 +
<source lang="xml">
 +
{% for group in groups %}
 +
  {% if group.bundle %}
 +
    {{ group.products.first.featured_image | product_img_url: 'small' }}
 +
    +
 +
    {{ group.products.last.featured_image | product_img_url: 'small' }}
 +
    =
 +
    {{ bundle.price }}
 +
  {% else %}
 +
    <!-- render other content here -->
 +
  {% endif %}
 +
{% endfor %}
 +
</source>
 +
|}
 +
 
 +
=== <tt>bundle</tt> ===
 +
The bundle variable is used to access extra information about bundles, not available in other groups:
 +
{| class="variable-ref-table"
 +
|-
 +
| text || Bundle’s buy message (e.g. “Buy both for $20”) which can be adjusted in the [http://shopify.directededge.com/settings#bundle Directed Edge for Shopify Bundle Settings] page.
 +
|-
 +
| price || The total price of a bundle calculated using the method specified in the [http://shopify.directededge.com/settings#bundle Directed Edge for Shopify Bundle Settings] page.  It can be formatted with the price filter just like elsewhere in Shopify templates: <source lang="xml">{{ bundle.price | money }}</source>
 +
|-
 +
| buy_link || A link that will add both products to the shopping cart and will ask the user to pick a variant if multiple variants are available for the bundled products.
 +
|}
 +
 
 +
 
 +
=== <tt>product</tt> ===
 +
 
 +
We support the same variables as Shopify, with the following additions.  See their documentation for <tt>[http://docs.shopify.com/themes/liquid-variables/product product]</tt>.
 +
 
 +
{| class="variable-ref-table"
 +
| buy_link || A link that will add the product to the shopping cart and will ask the user to pick a variant if multiple variants are available for the product.
 +
|}

Latest revision as of 12:32, 12 July 2018

See also our page with Shopify Liquid Examples.

Liquid variables supported by Directed Edge

groups

The liquid variable groups contain all recommendation types that are available for the requested page. Each group has following properties:

label A formatted label of the group, for example, “Recommended Items”, “Recently Viewed”, etc. Those labels can be customized in our Appearance Settings.
handle A machine friendly identifier for the group (e.g. bundle, recommended_product, etc.)
products An array of all of the products in returned for this recommendations group.

The following example would print title and price of all products in all available groups:

{% for group in groups %}
  <ul>
  {% for product in group.products %}
    <li>
    <b>{{ product.title }}</b><br />
    {{ product.price | money }}
  {% endfor %}
  </ul>
{% endfor %}

A detailed description of all product’s properties can be found here.

bundle A boolean field that indicates if this group is a bundle. This is useful to render custom content for that particular group. The following snippet would display both product images separated by a plus sign and followed by a equals sign and the bundle price:
{% for group in groups %}
  {% if group.bundle %}
    {{ group.products.first.featured_image | product_img_url: 'small' }}
    +
    {{ group.products.last.featured_image | product_img_url: 'small' }}
    =
    {{ bundle.price }}
  {% else %}
    <!-- render other content here -->
  {% endif %}
{% endfor %}

bundle

The bundle variable is used to access extra information about bundles, not available in other groups:

text Bundle’s buy message (e.g. “Buy both for $20”) which can be adjusted in the Directed Edge for Shopify Bundle Settings page.
price The total price of a bundle calculated using the method specified in the Directed Edge for Shopify Bundle Settings page. It can be formatted with the price filter just like elsewhere in Shopify templates:
{{ bundle.price | money }}
buy_link A link that will add both products to the shopping cart and will ask the user to pick a variant if multiple variants are available for the bundled products.


product

We support the same variables as Shopify, with the following additions. See their documentation for product.

buy_link A link that will add the product to the shopping cart and will ask the user to pick a variant if multiple variants are available for the product.