Hey guys,
I have added a message on our cart page, it loads fine but we only want it to show up when one or more products from a specific collection are in the basket.
I have attached an image of the message.
So it would be something like:
IF Cart has > 1 product(s) from the collection “collections/frontpage” then show the message.
How can I achieve that?
I’ve tried following numerous guides from here without luck but I can’t seem to get it to work.
I have included our cart page code below if needed and a link to preview the theme I’m working on.
The div I added was
on line 379.
Preview theme link (will work for 48hrs): https://6cut6u1iei4ps0tb-22594233.shopifypreview.com
{%- liquid
assign checkout_t = 'cart.checkout' | t
assign all_items_added_t = 'cart.all_items_added' | t
assign continue_t = 'cart.continue' | t
assign empty_html_t = 'cart.empty_html' | t: collections_url: routes.all_products_collection_url
assign minus_t = 'cart.minus' | t
assign order_notes_t = 'cart.order_notes' | t
assign plus_t = 'cart.plus' | t
assign price_t = 'cart.price' | t
assign quantity_t = 'cart.quantity' | t
assign remove_t = 'cart.remove' | t
assign subtotal_t = 'cart.subtotal' | t
assign total_t = 'cart.total' | t
assign your_cart_t = 'cart.your_cart' | t
if cart.taxes_included
assign shipping_taxes_t = 'cart.shipping_taxes_included' | t
else
assign shipping_taxes_t = 'cart.shipping_taxes_not_included' | t
endif
assign show_cart_note = settings.cart--show-note
assign has_items = false
if cart.item_count > 0
assign has_items = true
endif
-%}
{% for item in cart.items %}
{%- liquid
if item.variant.featured_media.preview_image
assign preview_image = item.variant.featured_media.preview_image
elsif item.product.featured_media.preview_image
assign preview_image = item.product.featured_media.preview_image
else
assign preview_image = false
endif
-%}
{% capture desktop_items %}
{{- desktop_items -}}
{%- liquid
if preview_image != false
render "image", image: preview_image
else
render "placeholder", type: 'product', aspect_ratio: 1, placeholder_index: 1
endif
-%}
{{ item.product.title }}
{% comment %} EDIT - 21st JULY 2022 - ADDED FLAIR BADGES TO CART PAGE - ADAM FROM BURST SUPPORT {% endcomment %}
{% render 'flair-product-badges', product: item.product, flair_layout: 'Cart Page' %}
{% unless item.variant.title contains 'Default' %}
{{ item.variant.title }}
{% endunless %}
{% if item.selling_plan_allocation %}
{{ item.selling_plan_allocation.selling_plan.name }}
{% endif %}
{% assign property_size = item.properties | size %}
{% if property_size > 0 %}
{% for property in item.properties %}
{% unless property.last == blank %}
{{ property.first }}:
{% comment %} Check if there was an uploaded file associated {% endcomment %}
{% if property.last contains '/uploads/' %}
{{ property.last | split: '/' | last }}
{% else %}
{{ property.last }}
{% endif %}
{% endunless %}
{% endfor %}
{% endif %}
{{ all_items_added_t }}
{% if item.original_price != item.final_price %}
~~{{ item.original_price | money }}~~
{% endif %}
{{ item.final_price | money }}
{%- liquid
if item.unit_price_measurement
echo item.unit_price | money | append: '/'
if item.unit_price_measurement.reference_value != 1
echo item.unit_price_measurement.reference_value
endif
echo item.unit_price_measurement.reference_unit
endif
-%}
{% if item.line_level_discount_allocations.size > 0 %}
{% for discount_allocation in item.line_level_discount_allocations %}
{{ discount_allocation.discount_application.title }} (-{{ discount_allocation.amount | money }})
{% endfor %}
{% endif %}
{% render 'icons', icon: 'minus' %}
{% render 'icons', icon: 'plus' %}
{{ remove_t }}
{% if item.original_line_price != item.final_line_price %}
~~{{ item.original_line_price | money }}~~
{% endif %}
{{ item.final_line_price | money }}
{% endcapture %}
{% capture mobile_items %}
{{- mobile_items -}}
{{ item.product.title }}
{% comment %} EDIT - 21st JULY 2022 - ADDED FLAIR BADGES TO CART DRAWER/MOBILE - ADAM FROM BURST SUPPORT {% endcomment %}
{% render 'flair-product-badges', product: item.product, flair_layout: 'Cart Drawer' %}
{{ all_items_added_t }}
{%- liquid
if preview_image != false
render "image", image: preview_image
else
render "placeholder", type: 'product', aspect_ratio: 1, placeholder_index: 1
endif
-%}
{% unless item.variant.title contains 'Default' %}
{{ item.variant.title }}
{% endunless %}
{% if item.selling_plan_allocation %}
{{ item.selling_plan_allocation.selling_plan.name }}
{% endif %}
{% assign property_size = item.properties | size %}
{% if property_size > 0 %}
{% for property in item.properties %}
{% unless property.last == blank %}
{{ property.first }}:
{% comment %} Check if there was an uploaded file associated {% endcomment %}
{% if property.last contains '/uploads/' %}
{{ property.last | split: '/' | last }}
{% else %}
{{ property.last }}
{% endif %}
{% endunless %}
{% endfor %}
{% endif %}
{% if item.original_price > item.final_price %}
~~{{ item.original_price | money }}~~
{% endif %}
{{ item.final_price | money }}
{%- liquid
if item.unit_price_measurement
echo item.unit_price | money | append: '/'
if item.unit_price_measurement.reference_value != 1
echo item.unit_price_measurement.reference_value
endif
echo item.unit_price_measurement.reference_unit
endif
-%}
{% if item.line_level_discount_allocations.size > 0 %}
{% for discount_allocation in item.line_level_discount_allocations %}
{{ discount_allocation.discount_application.title }}
(–{{ discount_allocation.amount | money }})
{% endfor %}
{% endif %}
{% render 'icons', icon: 'minus' %}
{% render 'icons', icon: 'plus' %}
{{ remove_t }}
{% endcapture %}
{% comment %} EDIT - 2nd JULY 2022 - ADDED POWER TOOLS "ADDED TO CART" TRACKING CODE - CHRIS FROM POWER TOOLS {% endcomment %}
{% comment %} {% endcomment %}
{% endfor %}
