Dynamically change Checkout Logo based on Product attributes?

anton_nv
Excursionist
20 1 5

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
1975 329 404

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 - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!