{"id":111309,"date":"2019-07-07T17:00:00","date_gmt":"2019-07-07T17:00:00","guid":{"rendered":"https:\/\/avada.io\/blog\/liquid-case-when-statement\/"},"modified":"2025-02-24T10:29:15","modified_gmt":"2025-02-24T10:29:15","slug":"liquid-case-when-statement","status":"publish","type":"post","link":"https:\/\/avada.io\/blog\/liquid-case-when-statement\/","title":{"rendered":"Liquid case when statement"},"content":{"rendered":"<p>You need help using the Liquid case when statement in Shopify? This feature can be tricky, but it\u2019s essential for customizing your store. In this guide, we\u2019ll show you exactly how to use the Liquid case when statement in Shopify, making it easier to manage and tailor your store\u2019s content. Let\u2019s dive in and solve this common challenge together.<\/p>\n<p><strong>Table of content<\/strong><\/p>\n<ul>\n<li><a href=\"#general-information-about-liquid-codes-and-tag-types\">General information about Liquid codes and tag types<\/a><\/li>\n<li><a href=\"#how-to-use-case-when-statement\">How to use case when statement<\/a><\/li>\n<\/ul>\n<h2 id=\"general-information-about-liquid-codes-and-tag-types\">General information about Liquid codes and tag types<\/h2>\n<p>Liquid codes are divided into objects, tags and filters. Double curly braces denote objects and variable names. Filters change a Liquid object\u2019s output. There are five main types of filters including string, number, boolean, nil and array. Tags create logic and control flow for a template. Tags begin with two curly braces and percent signs. Tags is classified into control flow, iteration and variable assignment.<\/p>\n<p>This tutorial focuses on control flow function by guiding you to use case\/when statements.<\/p>\n<h2 id=\"how-to-use-case-when-statement\">How to use case when statement<\/h2>\n<p>Case\/when statements create a switch statement to compare a variable with different values. In fact, <code class=\"language-plaintext highlighter-rouge\">case<\/code> starts with switching statement and <code class=\"language-plaintext highlighter-rouge\">when<\/code> compares its values. Your web will show the text or letter that you write in the first line of your code, if the input sentence is not valid, the web will not show.<\/p>\n<p><strong>Input<\/strong><\/p>\n<div class=\"language-plaintext highlighter-rouge\">\n<div class=\"highlight\">\n<pre class=\"highlight\"><code>\n{% assign handle = 'cake' %}\n{% case handle %}\n  {% when 'cake' %}\n     This is a cake\n  {% when 'cookie' %}\n     This is a cookie\n  {% else %}\n     This is not a cake nor a cookie\n{% endcase %}\n\n<\/code><\/pre>\n<\/div>\n<\/div>\n<p><strong>Output<\/strong><\/p>\n<div class=\"language-plaintext highlighter-rouge\">\n<div class=\"highlight\">\n<pre class=\"highlight\"><code>\nThis is a cake\n\n<\/code><\/pre>\n<\/div>\n<\/div>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>To sum up, the tutorial aims to guide you to <strong>use case\/when statements<\/strong>. Case\/when statements allows you to display right content if you insert characters which are the same as the initial ones. We hope that our article is helpful to you. Let\u2019s us know your difficulties and we will address them.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You need help using the Liquid case when statement in Shopify? This feature can be tricky, but it\u2019s essential for customizing your store. In this guide, we\u2019ll show you exactly how to use the Liquid case when statement in Shopify, making it easier to manage and tailor your store\u2019s content. Let\u2019s dive in and solve [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[356,383],"tags":[],"class_list":["post-111309","post","type-post","status-publish","format-standard","hentry","category-shopify","category-shopify-devdocs"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to use liquid case when statement in Shopify<\/title>\n<meta name=\"description\" content=\"Master the use of Liquid&#039;s case\/when statements to create dynamic content and personalized experiences for your Shopify store visitors based on various conditions.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/avada.io\/blog\/liquid-case-when-statement\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to use liquid case when statement in Shopify\" \/>\n<meta property=\"og:description\" content=\"Master the use of Liquid&#039;s case\/when statements to create dynamic content and personalized experiences for your Shopify store visitors based on various conditions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/avada.io\/blog\/liquid-case-when-statement\/\" \/>\n<meta property=\"og:site_name\" content=\"Avada Commerce\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/avada.io\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-07-07T17:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-02-24T10:29:15+00:00\" \/>\n<meta name=\"author\" content=\"Sam\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@avadaio\" \/>\n<meta name=\"twitter:site\" content=\"@avadaio\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sam\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to use liquid case when statement in Shopify","description":"Master the use of Liquid's case\/when statements to create dynamic content and personalized experiences for your Shopify store visitors based on various conditions.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/avada.io\/blog\/liquid-case-when-statement\/","og_locale":"en_US","og_type":"article","og_title":"How to use liquid case when statement in Shopify","og_description":"Master the use of Liquid's case\/when statements to create dynamic content and personalized experiences for your Shopify store visitors based on various conditions.","og_url":"https:\/\/avada.io\/blog\/liquid-case-when-statement\/","og_site_name":"Avada Commerce","article_publisher":"https:\/\/www.facebook.com\/avada.io\/","article_published_time":"2019-07-07T17:00:00+00:00","article_modified_time":"2025-02-24T10:29:15+00:00","author":"Sam","twitter_card":"summary_large_image","twitter_creator":"@avadaio","twitter_site":"@avadaio","twitter_misc":{"Written by":"Sam","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/avada.io\/blog\/liquid-case-when-statement\/#article","isPartOf":{"@id":"https:\/\/avada.io\/blog\/liquid-case-when-statement\/"},"author":{"name":"Sam","@id":"https:\/\/avada.io\/#\/schema\/person\/cc9c647e3ec94d00dc61ae2e653cafb7"},"headline":"Liquid case when statement","datePublished":"2019-07-07T17:00:00+00:00","dateModified":"2025-02-24T10:29:15+00:00","mainEntityOfPage":{"@id":"https:\/\/avada.io\/blog\/liquid-case-when-statement\/"},"wordCount":291,"publisher":{"@id":"https:\/\/avada.io\/#organization"},"articleSection":["Shopify","Shopify Devdocs"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/avada.io\/blog\/liquid-case-when-statement\/","url":"https:\/\/avada.io\/blog\/liquid-case-when-statement\/","name":"How to use liquid case when statement in Shopify","isPartOf":{"@id":"https:\/\/avada.io\/#website"},"datePublished":"2019-07-07T17:00:00+00:00","dateModified":"2025-02-24T10:29:15+00:00","description":"Master the use of Liquid's case\/when statements to create dynamic content and personalized experiences for your Shopify store visitors based on various conditions.","breadcrumb":{"@id":"https:\/\/avada.io\/blog\/liquid-case-when-statement\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/avada.io\/blog\/liquid-case-when-statement\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/avada.io\/blog\/liquid-case-when-statement\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/avada.io\/"},{"@type":"ListItem","position":2,"name":"Shopify","item":"https:\/\/avada.io\/category\/shopify"},{"@type":"ListItem","position":3,"name":"Shopify Devdocs","item":"https:\/\/avada.io\/category\/shopify-devdocs\/"},{"@type":"ListItem","position":4,"name":"Liquid case when statement"}]},{"@type":"WebSite","@id":"https:\/\/avada.io\/#website","url":"https:\/\/avada.io\/","name":"Avada Commerce","description":"Blog","publisher":{"@id":"https:\/\/avada.io\/#organization"},"alternateName":"Avada Commerce","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/avada.io\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/avada.io\/#organization","name":"Avada Commerce","alternateName":"Avada Commerce","url":"https:\/\/avada.io\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/avada.io\/#\/schema\/logo\/image\/","url":"https:\/\/avada.io\/wp-content\/uploads\/2023\/06\/Avada-logo.jpeg","contentUrl":"https:\/\/avada.io\/wp-content\/uploads\/2023\/06\/Avada-logo.jpeg","width":1200,"height":1200,"caption":"Avada Commerce"},"image":{"@id":"https:\/\/avada.io\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/avada.io\/","https:\/\/x.com\/avadaio","https:\/\/www.youtube.com\/@avadaio","https:\/\/www.linkedin.com\/company\/avadacommerce"]},{"@type":"Person","@id":"https:\/\/avada.io\/#\/schema\/person\/cc9c647e3ec94d00dc61ae2e653cafb7","name":"Sam","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/fdce01bbdb8b8eaa162f8ed372062707058abcd85e8b233af7cb4e01191c75f4?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/fdce01bbdb8b8eaa162f8ed372062707058abcd85e8b233af7cb4e01191c75f4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/fdce01bbdb8b8eaa162f8ed372062707058abcd85e8b233af7cb4e01191c75f4?s=96&d=mm&r=g","caption":"Sam"},"description":"Sam Nguyen is the CEO and founder of Avada Commerce, an e-commerce solution provider headquartered in Vietnam. He is an expert on the Shopify e-commerce platform for online stores and retail point-of-sale systems. Sam loves talking about e-commerce and he aims to help over a million online businesses grow and thrive.","sameAs":["https:\/\/wordpress-466542-3512282.cloudwaysapps.com","https:\/\/vn.linkedin.com\/in\/samng80"],"url":"https:\/\/avada.io\/authors\/sam\/"}]}},"meta_title":"How to use liquid case when statement in Shopify","meta_description":"Master the use of Liquid's case\/when statements to create dynamic content and personalized experiences for your Shopify store visitors based on various conditions.","meta_keywords":"","feature_image_custom":"","updated_at_migrate":"2024-08-28T21:43:02+07:00","_links":{"self":[{"href":"https:\/\/avada.io\/wp-json\/wp\/v2\/posts\/111309","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/avada.io\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/avada.io\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/avada.io\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/avada.io\/wp-json\/wp\/v2\/comments?post=111309"}],"version-history":[{"count":1,"href":"https:\/\/avada.io\/wp-json\/wp\/v2\/posts\/111309\/revisions"}],"predecessor-version":[{"id":117908,"href":"https:\/\/avada.io\/wp-json\/wp\/v2\/posts\/111309\/revisions\/117908"}],"wp:attachment":[{"href":"https:\/\/avada.io\/wp-json\/wp\/v2\/media?parent=111309"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/avada.io\/wp-json\/wp\/v2\/categories?post=111309"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/avada.io\/wp-json\/wp\/v2\/tags?post=111309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}