BACK

ahow to add and condition in shopify if statement

How to write an "if else" statement in Shopify 2.0 (Product Templates) all right what's going on guy

Roy Saucedo | Shopify Tutorials

Updated on Mar 17,2023

How to write an "if else" statement in Shopify 2.0 (Product Templates)

The above is a brief introduction to ahow to add and condition in shopify if statement

Let's move on to the first section of ahow to add and condition in shopify if statement

Let TThunt's experts help you find the best TikTok product on your Shopify business!

Find TikTok products (It's Free)
No difficulty
No complicated process
Find winning products
3.5K Ratings

WHY YOU SHOULD CHOOSE TTHUNT

TThunt has the world's largest selection of TikTok products to choose from, and each product has a large number of advertising materials, so you can choose advertising materials for TikTok ads or Facebook ads without any hassle.

ahow to add and condition in shopify if statement catalogs

How to write an "if else" statement in Shopify 2.0 (Product Templates)

all right what's going on guys so in,this tutorial i'm going to show you,how i use an if statement in order to,solve a specific problem for a client,so,here's the situation,uh this client they're using they're,actually using shopify in a very unique,way they're,an agency and they have they provide,services like social media,ads all that kind of stuff,and but they also want to sell products,and they all they want to have it all,flow through shopify right,so,they wanted on some pages they wanted,there to be,um,the call to action would be going to,like a calendly link to schedule a,call and other links they wanted to or,other product pages they wanted to,you know have like a subscription so,like you could be on a retainer with,them as for their marketing services,um so yes you kind of just got to be,clever with how you set this up and,um if i if it were me running this site,i would probably do a little bit,different probably run it through,webflow or something and you know have,the e-commerce flow through here or flow,through webs,or just run it through webflow too i've,never done that but,um i'm sure it's doable to an extent,um,but,so for this back to the back to what,we're doing here,for this,specific case i had to create different,product templates for different,services that they have right,so for example one service had was for,seo so seo had specific you know pricing,right but then you wouldn't say like,um 500 bucks plus,um,ten percent of ad spend right or,something like that,um they want for for one of the services,they wanted to add that kind of language,on there but that specific product had,different variants,so the price had to be dynamic but that,language had to be the same,um,so,let me let me show you guys kind of,a little bit about like an example,um just so you can kind of see the,difference so this is like a base,product right so,for this for my dev store i'm using,shoes right to,show,um,the uh,to like demonstrate this,um i didn't want to use their stuff for,i basically just downloaded their their,theme and uploaded into my dev store,because i wanted to give them give them,some privacy,um didn't get their consent,for making a video about them,but,i learned something today so i wanted to,share with you guys,so,here you'll see this uh regular product,has pricing there you know there's no,additional text on top of it it's just,the,um it's just the the price,but,for,the product that i'm talking about,we have,the price but then we also had some,language that we wanted to add on as,well so,for this scenario i added um the use,case of like oh yeah but let's let's add,like we're having a sale we want to have,this language everywhere so,um you know let's add 20 off using,the code sauce,um,you can see that this is a dynamic price,because i,select one of the other variants you'll,see the price changes you'll select this,one and the price changes so,the way i did this,because,was by making two different product,templates,in shopify,so before i get into this,let's,do it,um let me show you guys what that means,if you guys don't understand what,product templates are um,we'll kind of run through that really,quick,i want to preface this by i'm still,learning too uh i just want to share,this whatever info that i have for,anyone else who's learning to um,just want to throw that out there not,coming up here like a know-it-all,more just trying to share the share,knowledge,um,and all that good stuff so,let's go to products,so if you,and this only works for 2.0 stores by,the way guys um i know,there's like older themes on built on,shopify uh 1.0 i guess you'd call it,but for this specific situation it's for,2.0 stores which 2.0 stores have made my,life so much easier and makes shopify,even more fun,which is cool so you have your default,product template but then you also have,all these different other ones that you,can make right,so,for example one of them that,the nike shoe the the dunk was just a,regular product template and then i,created one for this one's called ads,it's for the agency,and it has the dynamic,pricing with little additional text so,um,if i was to not use this if statement,the price would just be here and i could,theoretically add an extra on this,template just add a piece of text on,here um but it just didn't look good,and i just wanted to show you guys,a different way to do it so,i like the way i did it i feel like it's,clean but you could easily i understand,that you could easily just add,a piece of text right here watch like,let's add it add a block,let's add,there you go text the camera's in the,way,and then you could add like whatever,language you want to do there,and then we could like shift it up so,it's right under there,and it's like under the price right so,then there's like some spacing there so,it's like i don't want to have to like,um,mess around with more styling and stuff,i felt like this solution was a little,bit cleaner so let me just hide that so,you guys can see that,let's save,and so let's get into it let's get into,the code,so,what we need to do is we're worrying,about price so i went ahead and found,the price snippet in our dawn theme,um you can see i just searched up price,and found it,then got it,so then i what i did is i looked for the,just the regular price because if you,see in the dawn theme they have like,sale price and it's like a whole,different element here that you that we,can edit and do that,um,but here we got the regular price so i,found this i was like awesome step one,done we can here's here is what we have,to edit,um,then i troubleshooted i,went ahead and,just added this text in there and i was,like all right cool let's see if it,shows up um and it did which is awesome,but then it also showed up on my regular,product too,right so i'll even i'll show you guys,what it would look like if i remove this,so let me just have this element,just have this show up,and then,put it back there just so i can have it,and then,let's boop,all right and let's save it,let's see what it does hopefully it'll,break everything,and oh no it removed it right,so,that's what that's how it looked like,before so if i even just add like,hi,everyone and save it,you'll see that it updates over here too,right so that's kind of like you kind of,find where you're working with and then,you build off of it,so i was like alright cool i'm editing,now i know i'm editing the right spot,it's showing up,and so i was like all right cool how do,i just specifically target,uh,the product template right because it's,that's the use case that i want to work,off of like just that specific product,template when that's how when that's,live when that's displaying do this and,then if not just show regular price,so here's the here's the if statement,that we're using so,we went ahead and used product dot,template suffix,is equal to,ads,ads is the name of the product template,so all you need to do is add the little,the name of it you don't need to add,like product or ads dot,json or something um you could just,adds,then you go ahead and add your use case,for that so when this happens when this,is when this is correct,do this,and then you're saying else so if,anything else is the case,just do this,so just show the regular price and then,we're gonna with every if statement you,got to end it so,if and then end if,and we save it,and then let's go back let's make sure,to see if it let's see if it shows up,again right,it shows up correctly come on man and,we're good perfect so look it let's it,shows up on this one this product,template but,let's go to our nike dunk,lucky dunk retro,and it's regular pricing what do you,know so,that's pretty much it guys um just,wanted to show you,that tutorial um using if statements in,shopify how to select it how to select,specific product templates,and do logic around that so you you can,kind of use that for lots of different,things right basically what i wanted to,show you was how to select,how to create logic based off of a,specific product template,that's pretty much it,i had fun doing this sharing it hope it,was fun for you,if you have any questions or you want to,see any more videos feel free to leave,comments down below subscribe to my,channel,please that'd be awesome um would love,to,build this community create more,resources for each other and and just to,you know build more build more cool,stuff so,that's pretty much it i hope you guys,have an amazing rest of your day and,i'm out peace

Congratulation! You bave finally finished reading ahow to add and condition in shopify if statement and believe you bave enougb understending ahow to add and condition in shopify if statement

Come on and read the rest of the article!

Browse More Content