Hi there,
Is it possible to hide products with “0.00” price from appearing in the recommended products section? Ideally without an app.
Hi there,
Is it possible to hide products with “0.00” price from appearing in the recommended products section? Ideally without an app.
Hello , @nealandwolf
Use this condition in your recommendation products section/snippet code. Inside forloop
{% if product.price > 0 %}
Thanks for the fast reply! Could you take a look at the code below and let me know where to add in? I’ve tried a few different ways but not been able to make it work.
{%- assign recommend_products = true -%}
{% if recommendations.products and recommendations.products_count > 0 %}
{%- assign related_collection = recommendations -%}
{% endif %}
{% comment %}
Check if the utility tag defines related section
{% endcomment %}
{% for tag in product.tags %}
{% if tag contains ‘related’ %}
{%- assign include_collection_handle = tag | split: '’ | last -%}
{%- assign include_collection = collections[include_collection_handle] -%}
{% if include_collection != empty and include_collection.products_count > 0 %}
{%- assign related_collection = include_collection -%}
{%- assign recommend_products = false -%}
{% break %}
{% endif %}
{% endif %}
{% endfor %}
{%- assign number_of_products = section.settings.related_count -%}
{%- assign per_row = number_of_products -%}
{%- assign number_of_products_to_fetch = number_of_products | plus: 1 -%}
{% case per_row %}
{% when 1 %}
{%- assign grid_item_width = ‘’ -%}
{% when 2 %}
{%- assign grid_item_width = ‘medium-up–one-half’ -%}
{% when 3 %}
{%- assign grid_item_width = ‘small–one-half medium-up–one-third’ -%}
{% when 4 %}
{%- assign grid_item_width = ‘small–one-half medium-up–one-quarter’ -%}
{% when 5 %}
{%- assign grid_item_width = ‘small–one-half medium-up–one-fifth’ -%}
{% when 6 %}
{%- assign grid_item_width = ‘small–one-half medium-up–one-sixth’ -%}
{% endcase %}
{%- if section.settings.show_product_recommendations -%}
{% if settings.quick_shop_enable %}
{% for product in related_collection.products limit: number_of_products_to_fetch %}
{% if product.handle != current_product.handle %}
{% include ‘quick-shop-modal’ %}
{% endif %}
{% endfor %}
{% endif %}
{% schema %}
{
“name”: “Product recommendations”,
“settings”: [
{
“type”: “checkbox”,
“id”: “show_product_recommendations”,
“label”: “Show dynamic recommendations”,
“info”: “Dynamic recommendations change and improve with time. Learn more”,
“default”: true
},
{
“type”: “text”,
“id”: “product_recommendations_heading”,
“label”: “Heading”,
“default”: “You may also like”
},
{
“type”: “range”,
“id”: “related_count”,
“label”: “Number of related products”,
“default”: 5,
“min”: 2,
“max”: 6,
“step”: 1
}
]
}
{% endschema %}
That’s perfect, thank you so much!