1. Home
  2. Docs
  3. Liquid Web Shopify Coding...
  4. Liquid Code Examples

Liquid Code Examples

  1. Displaying Product Information:
{% if product.available %}
<h1>{{ product.title }}</h1>
<p>{{ product.description }}</p>
<p>Price: {{ product.price | money }}</p>
{% else %}
<h1>Sorry, this product is currently sold out</h1>
{% endif %}

This code checks to see if a product is available and then displays its title, description, and price using Liquid’s conditional statements and filters.

  1. Creating a Collection List:
{% for collection in collections %}
<h2>{{ collection.title }}</h2>
<ul>
{% for product in collection.products %}
<li>{{ product.title }}</li>
{% endfor %}
</ul>
{% endfor %}

This code loops through each collection on a Shopify store and displays its title, followed by a list of all the products in that collection.

  1. Displaying Blog Posts:
{% for article in blog.articles %}
<h2>{{ article.title }}</h2>
<p>{{ article.excerpt }}</p>
<a href="{{ article.url }}">Read more</a>
{% endfor %}

This code displays a list of blog articles on a Shopify store, including their titles, excerpts, and links to the full article.

These are just a few examples of the types of templates that can be created using Shopify Liquid. With Liquid, developers can create custom storefronts and themes that are fully customized to their brand and business needs.

How can we help?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.