Reader small image

You're reading from  Shopify Theme Customization with Liquid

Product typeBook
Published inOct 2021
PublisherPackt
ISBN-139781801813969
Edition1st Edition
Tools
Right arrow
Author (1)
Ivan Djordjevic
Ivan Djordjevic
author image
Ivan Djordjevic

Ivan Djordjevic comes from the small town of Prokuplje, Serbia. As a self-taught developer, he spent the first few years working on different projects, but only when he came in contact with Shopify and learned about Liquid that he found himself. In 2016, Ivan joined Shopify Experts under HeyCarson, where he moved to the lead developer position after a few months. Since joining the Shopify family, Ivan found his passion in sharing his knowledge with other developers and guiding them on their way to becoming a Shopify Expert.
Read more about Ivan Djordjevic

Right arrow

Chapter 1, Getting Started with Shopify

Question 1

What is the Partners program?

Answer

The Partners program is a platform created by Shopify that assembles people from all over the world. Through this platform, we can build new ecommerce stores for store owners, design themes, develop apps, refer new clients to Shopify, and most importantly, create a development store for us to practice. We can remind ourselves of this within the How to start? topic.

Question 2

How can we disable the password protection of the development type store?

Answer

We can disable our password protection store by clicking on the See store password button within the banner on the Themes section, located under the Online store section, or by selecting the Online store and subsequently clicking the Preferences inside the expanded dropdown. Once inside, we can easily remove the password protection on the regular store. However, since our store is in development mode, this option is currently...

Chapter 2, The Basic Flow of Liquid

Question 1

What type of delimiter should we use if we are expecting an output as a result?

Answer

If we expect output from Liquid code, we should use a double bracket delimiter, as we should only use a bracket with a percentage when performing a certain logic. We can remind ourselves about this within the Understanding Liquid and its delimiters section.

Question 2

What will the result of the following conditional be, and why?

{% if collection.all_products_count > "20" %}
  The number of products in a collection is greater 
   than 20!
{% endif %}

Answer

Considering that collection.all_products_count by default returns a number as its value, where the value we are comparing it against is a string since it is encapsulated inside the parentheses. Since we cannot compare values of different types, the conditional will return false, and our message will not be shown. We can remind ourselves...

Chapter 3, Diving into Liquid Core with Tags

Question 1

What parameters should we use inside a for loop if we want to show a maximum of seven iterations while also skipping the first three iterations?

Answer

If we are looking to create a loop that will skip the first three iterations and output a maximum of seven iterations, we should use a combination of the offset and limit parameters. The offset tag will allow us to skip any number of iterations, depending on the value we assign to it. The limit parameter will allow us to limit the number of iterations the tag should perform. We can remind ourselves of this by revisiting the for parameters subsection of the Iterations tags section.

Question 2

What types of data can we assign to a variable created using the capture tag?

Answer

We can assign any type of data to a variable created using the capture tag. However, a variable created using the capture tag will always return string data as a result. We can remind ourselves...

Chapter 4, Diving into Liquid Core with Objects

Question 1

What are we missing in the following block of code to make form functional?

{% form "product", product %}
  <input type="hidden" value="{{ 
   product.first_available_variant.id }}" />
    <input type="submit" value="Add to Cart"/>
{% endform %}

Answer

While we have introduced the id variant, which is necessary to create a working product form, we didn't use a name attribute with id as its value. We can remind ourselves of how this works by going back to the Custom collection subtopic, in the Working with global objects section.

Question 2

How can we get access to the product object through a link defined in the admin navigation?

Answer

To access the product object through the navigation menu, we will need to use a for tag to iterate over the navigation menu. Once we have found which menu item...

Chapter 5, Diving into Liquid Core with Filters

Question 1

Suppose that we have an array named product_handles with handles of 30 products. What issue in the following code would prevent us from outputting the images of all 30 products successfully?

{% for handle in product_handles %}
  {% assign product_object = all_products[handle] %}
  {% for image_item in product_object.images %}
    <img src="{{ image_item | img_url }}"/>
  {% endfor %}
{% endfor %}

Answer

Since we are looking to output more than 20 products, in this case, 30 products, we cannot use the all_products object, as the all_products object has a limitation that we can only call it 20 times on a single page. If we are looking to recover data from more than 20 products, we need to assign them to a collection and then perform a loop over those products. We can remind ourselves of the all_products object by visiting the Working with HTML and URL...

Chapter 6, Configuring the Theme Settings

Question 1

What are the two types of input settings?

Answer

The first set of settings is called basic input types, and it consists of six types of settings, which allow us to output basic HTML input elements through which we can dynamically output certain content. The second set of settings, otherwise called specialized settings, allows us to generate specialized selector type fields to access various objects through the store and output their content using their attributes. We can remind ourselves of the basic and specialized input types of settings by visiting the Basic input types and Specialized input settings sections in Chapter 6, Configuring the Theme Settings.

Question 2

What's the issue that will cause an error with the following piece of code?

{
  "type": "text",
  "id": "header_announcement",
  "label": "Text",
}

Answer...

Chapter 7, Working with Static and Dynamic Sections

Question 1

What is the main difference between the static and dynamic sections?

Answer

The main difference between the static and dynamic sections is that we can only add the dynamic section to the JSON templates and the home page using the Add section button inside the theme editor. Additionally, we can repeat this any number of times with different content.

On the other hand, the static section needs to be included manually inside a theme template using the section tag. We can include the same static section inside multiple templates. However, each section will display the same content as we can only have one instance of a static section. We can remind ourselves of static and dynamic sections by visiting the Static versus dynamic sections section.

Question 2

What object can we use to access the block input value? Write some code that will allow us to access the specific blocks module input value.

Answer

We...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Shopify Theme Customization with Liquid
Published in: Oct 2021Publisher: PacktISBN-13: 9781801813969
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at AU $19.99/month. Cancel anytime

Author (1)

author image
Ivan Djordjevic

Ivan Djordjevic comes from the small town of Prokuplje, Serbia. As a self-taught developer, he spent the first few years working on different projects, but only when he came in contact with Shopify and learned about Liquid that he found himself. In 2016, Ivan joined Shopify Experts under HeyCarson, where he moved to the lead developer position after a few months. Since joining the Shopify family, Ivan found his passion in sharing his knowledge with other developers and guiding them on their way to becoming a Shopify Expert.
Read more about Ivan Djordjevic