Shopify Tutorials
Shopify Liquid for Beginners
Start learning Shopify's Templating Language today!
Get current url of any page
Adding the correct shipping price with discounts
Get product count and variant count of store
Conditional Statements - Extended
After learning the basics of conditional statements, we explore the contains, unless, and case operators. The contains operator is used to check a string in within a string or a string within an array of strings. The unless operator runs code if the statement is false. The case operator simplifies many if statements.
Sections are not showing up in theme customize
Conditional statements
The foundation of conditional statements can be boiled down to this: if this is true then run this code. You can also expand on that: if this is true then run this code, if not run a different code. Chaining conditions is common with different comparison operators using "or"/"and" to check if values are true or false.
Comparison operators
Comparison operators are exactly that, comparing two values in different ways. The output of comparing values will be a boolean, true or false. The Liquid operators: greater than >, greater than or equal to >=, less than <, less than or equal to <=, equal to ==, does not equal to !=, the and operator, the or operator.
Types of Data
Variables, assignments, and naming conventions
Variables are a way to save data. The way it is done in Liquid is to use the "assign" tag between these curly braces and percent signs {% %}. You can still manipulate this data after it is assigned. When you name a variable it is a best practice to give it a label that is meaningful to what is happening in the code.