How can I combine codes to hide and reveal collection prices?

Hi Shopify guys,

I have a little challenge combining the code below.

I need to hide the price of a given collection, which I can do with this code:

{% unless collection.handle contains ‘[collection-handle]’ %}{% render ‘price’, product: card_product, price_class: ‘’, show_compare_at_price: true %} {% endunless %}

But it must be possible to see the price by logging in, which I can do with this code:

{% if customers %}{% render ‘price’, product: card_product, price_class: ‘’, show_compare_at_price: true %} {% else %} [LINK TO LOGIN] {% endif %}

How do I combine the above so that it only affects a given collection, while the price is visible on other collections, regardless of whether you are logged in or not?

Thanks in advance for the help :0)

Hi @BayOfDenmark ,

Please find the combined code below:

{% unless collection.handle contains '[collection-handle]' %}
    {% render 'price', product: card_product, price_class: '', show_compare_at_price: true %}
{% else %}
    {% if customers %}
        {% render 'price', product: card_product, price_class: '', show_compare_at_price: true %} 
    {% else %} 
        [LINK TO LOGIN]
    {% endif %}
{% endunless %}

If you require further help to customize your store, please don’t hesitate to reach out. If you find this information useful, a Like would be greatly appreciated. And if this solves the problem, please Mark it as Solution!

Best Regards,
Makka