Shopify vendor if statement

1.4k views Asked by At

A shopify liquid question:

If no vendor is available, then shopify adds the shop name as the default vendor. I'd like those instances to be blank.

I'm trying to create an if statement which hides the vendor if there is no vendor or if it equals the default vendor name.

Here's what I've come up with so far and I'm now stuck

<div class="prod-caption">{% if product.vendor == 'test' %} {% else %} {{ product.vendor }} {% endif %} {{ product.title }}</div>

I want to do this on the product page as well as in the product grid item snippet

Can anyone help?

1

There are 1 answers

1
Steph Sharp On BEST ANSWER

What you've got looks like it should work (assuming you replace 'test' with your shop's name), but I'd probably write the if statement like this:

{% if product.vendor != shop.name %}{{ product.vendor }}{% endif %} {{ product.title }}

This will work in both product.liquid and product-grid-item.liquid. (Just search for {{ product.title }} and replace it with the code above.)