Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi there,
We are doing a promotion on certain items and want to replace the store logo if someone has one of these items in their cart at checkout.
I have the following so far but checkout.liquid doesnt seem to recognise any of it, though it works for the notifications?
{% assign mc_product = false %}
{% assign mc_product_logo = "https://cdn.shopify.com/s/files/1/0554/6452/5977/files/mc-logo.png?v=1636209121" %}
{% for line in line_items %}
{% if line_item.sku contains 'NMC' %}
{% assign mc_product = true %}
{% endif %}
{% endfor %}
<header class="banner" data-header role="banner">
<div class="wrap">
{%- if mc_product == true -%}
<img src="{{mc_product_logo}}">
{% else %}
{{ content_for_logo }}
{%- endif %}
</div>
I know checkout.liquid is quite restricted, even though we are on Plus. Having said that we have put in Shipping Estimators that are just built in liquid - whats the deal?
Cant really do this using JS as the data to identify the products is not shown front-end (getElement... etc)
Hi @anton_nv,
Please change the code:
{% for line in line_items %}
{% if line_item.sku contains 'NMC' %}
{% assign mc_product = true %}
{% endif %}
{% endfor %}
=>
{% for line_item in checkout.line_items %}
{% if line_item.sku contains 'NMC' %}
{% assign mc_product = true %}
{% break %}
{% endif %}
{% endfor %}
Hope it helps!
Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025Expand into selling wholesale with Shopify Academy’s learning path, B2B on Shopify: Lau...
By Shopify Jan 28, 2025