Dynamically change Checkout Logo based on Product attributes?

Dynamically change Checkout Logo based on Product attributes?

anton_nv
Shopify Partner
25 1 7

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)

Reply 1 (1)

LitExtension
Shopify Partner
4901 1004 1176

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!

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
Contact us:
- Email: contact@litextension.com