Add product-variant specific note in Cart

Hello there, I’ve searched for hours to find a way to achieve that unsuccesfully…

I sell a product with multiple variants (a digital version, and multiple sizes variants of a physical version).
I would like if the digital product variant is added to the cart, to have a specific message/note displayed. Only for this product variant is in the cart.

Is anyone have an idea how this could be achieved?

Thank you in advance,

Hi @PatrickRoy ,

You just want it to show on the cart page, you can add conditions to show it.

Please send me the code of main-cart-items.liquid file, I will help you add condition to display it at cart page.

Hi Lit, thanks for your reply!

I do not have a file called main-cart-items, (using debutify theme) … this might be a similar page cart-page.liquid?

{%- assign total_compare_at_price = 0 -%}
{%- assign gift_wrap_product_id = settings.dbtfy_gift_wrap_product.id -%}

{{ 'cart.general.title' | t }}

{%- if cart.item_count == 0 -%}

{{ 'cart.general.empty' | t }}

{{ 'cart.general.cookies_required' | t }}

{{ 'cart.general.continue_browsing_html' | t }}
{%- endif -%}

{%- if cart.item_count > 0 -%}

{%- for item in cart.items -%} {%- liquid if item.variant.compare_at_price > 0 and item.variant.compare_at_price > item.variant.price assign total_compare_at_price = item.variant.compare_at_price | times: item.quantity | plus: total_compare_at_price else assign total_compare_at_price = item.variant.price | times: item.quantity | plus: total_compare_at_price endif

if item.original_line_price != item.final_line_price
assign has_discount = true
else
assign has_discount = false
endif

if item.variant.compare_at_price > item.variant.price
assign on_sale = true
else
assign on_sale = false
endif
-%}

{%- unless item.variant.title contains ‘Default’ -%}

{{ item.variant.title }}

{%- endunless -%}

{%- liquid
assign property_size = item.properties | size
-%}

{%- if property_size > 0 -%}

{%- for p in item.properties -%}
{%- assign first_character_in_key = p.first | truncate: 1, ‘’ -%}

{%- unless p.last == blank or first_character_in_key == ‘_’ -%}

{{- p.first | append: ':' | append: ' ' -}}

{%- if p.last contains ‘/uploads/’ -%}
{{ p.last | split: ‘/’ | last }}
{%- else -%}
{{- p.last -}}
{%- endif -%}

{%- endunless -%} {%- endfor -%} Edit Options {%- endif -%}

{%- if item.line_level_discount_allocations != blank -%}

{%- for discount_allocation in item.line_level_discount_allocations -%}

local_offer {{ 'customer.order.discount' | t }}: {{ discount_allocation.discount_application.title }}

-{{ discount_allocation.amount | money }}

{%- endfor -%}
{%- endif -%}
{%- capture quantity_selector -%}
{%- assign quantity_id = 'updates_' | append: item.key -%}

{{ ‘cart.label.quantity’ | t }}

{%- render ‘quantity-selector’ with item as item, type: ‘cart’, id: quantity_id -%}

{%- endcapture -%}

{%- if settings.dbtfy_gift_wrap -%}
{%- unless item.product.id == gift_wrap_product_id -%}
{{ quantity_selector }}
{%- endunless -%}
{%- else -%}
{{ quantity_selector }}
{%- endif -%}

{%- if has_discount -%} {{ item.final_line_price | money }} {{ item.original_line_price | money }} {%- elsif on_sale -%} {{ item.variant.price | times: item.quantity | money }} {{ item.variant.compare_at_price | times: item.quantity | money }} {% else %} {{ item.original_line_price | money }} {%- endif -%}

{%- if item.unit_price_measurement -%}
{{ ‘products.general.unit_price’ | t }}

{%- capture unit_price_separator -%}
/ {{ ‘general.accessibility.unit_price_separator’ | t }} 
{%- endcapture -%}

{%- capture unit_price_base_unit -%}
{%- if item.unit_price_measurement.reference_value != 1 -%}
{{- item.unit_price_measurement.reference_value -}}
{%- endif -%}

{{ item.unit_price_measurement.reference_unit }}
{%- endcapture -%}

{{ item.unit_price | money }}{{- unit_price_separator -}}{{- unit_price_base_unit -}}

{%- endif -%}

{%- endfor -%}

{%- render “dbtfy-delivery-date”, position: “cart_page” -%}
{%- render “dbtfy-cart-discount”, position: “cart_page” -%}

{%- render “dbtfy-gift-wrap”, position: “cart_page” -%}

{%- if settings.cart_notes_enable -%}

info {{ 'cart.general.note' | t }} {{ cart.note }}
{%- endif -%}

{%- render ‘dbtfy-order-feedback’ -%}

{%- if cart.cart_level_discount_applications != blank -%} {%- for discount_application in cart.cart_level_discount_applications -%}

local_offer {{ 'customer.order.discount' | t }}: {{- discount_application.title -}}

-{{ discount_application.total_allocated_amount | money }}

{%- endfor -%} {%- endif -%}

{{ 'cart.general.subtotal' | t }}

{{ cart.total_price | money }}

{%- render “dbtfy-cart-savings”, cart: cart, total_compare_at_price: total_compare_at_price -%}

{%- render “dbtfy-agree-to-terms” -%}

{%- capture taxes_shipping_checkout -%}
{%- if shop.taxes_included and shop.shipping_policy.body != blank -%}
{{ ‘cart.general.taxes_included_and_shipping_policy_html’ | t: link: shop.shipping_policy.url }}
{%- elsif shop.taxes_included -%}
{{ ‘cart.general.taxes_included_but_shipping_at_checkout’ | t }}
{%- elsif shop.shipping_policy.body != blank -%}
{{ ‘cart.general.taxes_and_shipping_policy_at_checkout_html’ | t: link: shop.shipping_policy.url }}
{%- else -%}
{{ ‘cart.general.taxes_and_shipping_at_checkout’ | t }}
{%- endif -%}
{%- endcapture -%}

{%- if taxes_shipping_checkout != blank -%}

{{ taxes_shipping_checkout }}

{%- endif -%}

{%- if settings.tracking_app == “route” -%}

{%- endif -%}

{%- if settings.dbtfy_minimum_order -%}
{%- render “dbtfy-minimum-order”, cart_type: “page” -%}
{%- else -%}
{%- render “checkout-button”, type: “page” -%}
{%- endif -%}

{%- unless request.design_mode -%}
{%- if additional_checkout_buttons and settings.enable_payment_button and settings.position != ‘drawer’ -%}

{{ content_for_additional_checkout_buttons }}
{%- endif -%} {%- endunless -%}

{%- render “dbtfy-trust-badge”, position: “cart_page” -%}

{%- assign currency_message = ‘cart.general.custom_currency_html’ | t: shopCurrency: shop.currency -%}

{%- if settings.dbtfy_custom_currencies and currency_message != blank -%}
{%- if settings.currency_message -%}

{{ currency_message }}

{%- endif -%} {%- endif -%}
{%- endif -%}
{% comment %}{% endcomment %}

Hi @PatrickRoy ,

Please add code here:

Code:

{%- if item.variant.title contains 'variant digital' -%}
  

message

{%- endif -%}

You need to change ‘variant digital’ and ‘message’ according to your condition.

Hope it helps!

Hi @LitExtension , it works like a charm! Thank you greatly, I just learned so much with just that little bit of code. I hope it helps others in the future!

Thanks again, cheers