Collection variants

New Member
25 0 0

Hi !

I have products that have variants (and so different prices) and other products (from a different collection) that have one price only.
For a specific collection, I would like to display "from" before the price.
Is that possible ?
Best

0 Likes
Highlighted
Astronaut
1011 131 240

Yes, I assume you're talking about on the collection page. In collection.liquid around where the price occurs you just have to add an if statement.

{% if collection.handle == "your-collection-handle" %}
<div class="product-price"> From: {{ product.price }}</div>
{% else %}
<div class="product-price">{{ product.price }}</div>
{% endif %}

Something like that. I can't say for certain where to put it because I don't know what your liquid code looks like.

If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish :D
0 Likes
New Member
25 0 0

I am not sure I have this configuration.

In product-price-liquid (debut theme), I have: 

 

      <span class="price-item price-item--regular" data-regular-price>
        {% if available %}
          {% if compare_at_price > price %}
            {{ compare_at_price | money }}
          {% else %}
           {{ money_price }}
          {% endif %}
        {% else %}
          {{ 'products.product.sold_out' | t }}
        {% endif %}
      </span>

I can change            {{ money_price }} to      From      {{ money_price }}. And it works for all collections.
I tried to make what you suggested (i.e.):

  {% if collection.handle == 'Embroidery-Kits' %}
        From {{ money_price }}
        {% else %}
        {{ money_price }}
        {% endif %}

But I was not successfull.
Best

0 Likes
Astronaut
1011 131 240

That's because the collection object probably isn't available on that page. I was assuming you were on collection.liquid. Uh, you could check the products collection by looping through them, and checking to make sure it's the collection you want in case it's in more than one collection:

     <span class="price-item price-item--regular" data-regular-price>
        {% if available %}
          {% if compare_at_price > price %}
            {{ compare_at_price | money }}
          {% else %}
          {% for collection in product.collections %}
            {% if collection.handle == "Embroidery-Kits" %}
             From: {{ money_price }}
            {% else %}
            {{ money_price }}
          {% endif %}
          {% endfor %}
          {% endif %}
        {% else %}
          {{ 'products.product.sold_out' | t }}
        {% endif %}
      </span>

That's assuming your "Embroidery-Kits" handle is correct. I believe all handles are all lowercase with "-" in place of whitespace .

If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish :D
0 Likes
Shopify Expert
9780 86 1528

A product has a property in place that lets you determine if the price varies or not for variants:
https://help.shopify.com/en/themes/liquid/objects/product#product-price_varies

Why does this need to be added to just once collection? I would have expected you to just use something like this as you loop over the products:

{% if product.price_varies %}From {% endif %}

^ so if the price varies, show from. If not, continue as normal.
 

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
1 Like
Astronaut
1011 131 240

Well shit, that makes perfect sense. I guess I was just thinking about how he said his one collection had different variants and I locked on that as a way to separate it. Listen to Jason, he knows what he's talking about.

If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish :D
0 Likes
New Member
25 0 0

Thanks for all your answers.

@ Jason: this simple solution did it. Thanks !

0 Likes