Adding Conditional Logic to Product Badges

Video Transcript

Okay. In this video, we're going to talk about how to add conditional logic to your badges on your product page. So I've already got a set of four badges that I've added to my product template. But the way they're set up right now is they show up on all the product pages, regardless of product characteristics. So, for example, maybe not all of our products in the store are made of carbon fiber.

Maybe all of them don't have a limited warranty. So we're going to go into the air and add in some conditional logic to only show certain badges on certain conditions. So let's go into our Shopify admin. I've already got the Badge Zilla app pins to the app listing, so I'm going to open that up and you'll see the four badges that we saw on the front end of the website showing up here under the product tab under Choose Badges.

And what we're going to do is we're going to click on that add condition icon and look at adding conditions for them. Before we do that I want to show you the product that we're looking at which is the complete snowboard here. So that's this one. And you'll see that the title of this is the complete snowboard. And we've also got some tags.

There's a maiden can add a tag and a carbon fiber tag. So knowing that information I'm going to go into the Badge Zilla app. And for the maiden Canada product seal I'm going to add a condition. So it brings up this modal. And remember that was a tag. So I'm going to select tags and contains. And then it was made in Canada.

And we want to display the badge if that is the case. So we hit save. Same thing for carbon fiber. That was a tag. So we're going to have tags contains carbon fiber.

I'm going to display the badge. In that case. And the last one we'll have a condition on. We'll put it on the one year limited warranty. And we'll say that anything with the product title contains snowboard. And whatever text you put in here is not case sensitive. So if it happens, you capitalize or not capitalize, you can get it wrong.

That'll be okay. In this case, we want to display the badge. So I'm going to save that. Now I'm just going to go into the last. We're not going to save the condition. We look at here. But I want to show you that how many pieces of information we can look at. Right. We can look at the product type.

We can look at the tags. We can look at any meta field that you've added to your products. We can also look at the price, the availability, the product title, the inventory and the vendor. And depending on which one you pick, the logic will change. So you can see product type has these set of rules. But if we go down to let's say inventory, which is a number we're going to have is equal to is greater than is less than rules.

So the rules will change based on the data type that you select. And that gives you lots of flexibility on, you know, the complexity of the rule structure that you put in place. So the nice thing about this is you could, you know, add ten different products deals, which is a lot for a product page. But with all this conditional logic, you're only showing 3 or 4 on any given product based on what rules you set up and how that product matches to those rules. So now we have, save these settings and we're going to go out to the front end and we're actually going to all these are still going to stay because all those conditions are true.

But if I go into another snowboard, you'll see that this one has the one year limited warranty because it has snowboard in the title, but it doesn't show the made in Canada in carbon fiber because we didn't have this snowboard tagged with those tags. So you can see that the conditional logic is working here. So that's how you can have the appropriate product seals show up on your product page based on rules that you can set inside the Badgezilla app.

Thanks for watching.

Back to blog