How to show Announcement bar only on Cart page

Solved

How to show Announcement bar only on Cart page

amisha-29
Shopify Partner
93 1 23

I want to show Announcement bar only on Cart page not on every page how can i do this? I'm using dawn theme currently.

Accepted Solution (1)

AnneLuo
Shopify Partner
1361 237 279

This is an accepted solution.

Hi, @amisha-29 

Steps:
1. Go to your Shopify Admin:
Online Store > Themes > Dawn > Edit code

2. Locate the announcement bar section:
Find and open:
sections/announcement-bar.liquid

3. Add a condition to render only on the cart page:
Wrap the entire content of the announcement bar with this {% if %} condition:

{% if request.page_type == 'cart' %}
<!-- Original announcement bar code here -->
{% endif %}


Your updated announcement-bar.liquid might look like this:

 

{% if request.page_type == 'cart' %}
<div class="announcement-bar">
<!-- existing announcement bar HTML here -->
</div>
{% endif %}

 

If you will unable to implement the same then I'm happy to do this for you, let me know.

Hope this helps! If yes then Please don't forget hit Like and Mark it as solution!

 

If this is helpful, please Like and Accept the solution.
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me   

Buy Me A Coffee

View solution in original post

Replies 5 (5)

topnewyork
Astronaut
1536 189 250

Hi @amisha-29,


1. Go to Online Store -> Theme -> Edit code.
2. Open your theme.liquid file
3. In theme.liquid, paste the below code before </head>

<script>
  document.addEventListener("DOMContentLoaded", function () {
    const bar = document.querySelector('.announcement-bar-section');

    if (!bar) return;

    if (window.location.pathname === '/cart') {
      bar.classList.remove('hide-bar');
    } else {
      bar.classList.add('hide-bar');
    }
  });
</script>

<style>
  .hide-bar {
  display: none !important;
}

</style>

Thanks!

Need a Shopify developer? Hire us at Top New York Web Design
Boost Your Store Sales with Volume/Tier Discount Try Big Bulk Discount
Create New Shopify Store For Just 1$/Month
amisha-29
Shopify Partner
93 1 23

I added this code as you told me but now I'm not able to see anything for the header section so i can add that announcement bar only on my cart page. Header section is not showing.

amisha29_0-1749149177931.png

 

steve_michael2
Navigator
454 39 62

Hello @amisha-29 ,

Can you please share store URL?

AnneLuo
Shopify Partner
1361 237 279

This is an accepted solution.

Hi, @amisha-29 

Steps:
1. Go to your Shopify Admin:
Online Store > Themes > Dawn > Edit code

2. Locate the announcement bar section:
Find and open:
sections/announcement-bar.liquid

3. Add a condition to render only on the cart page:
Wrap the entire content of the announcement bar with this {% if %} condition:

{% if request.page_type == 'cart' %}
<!-- Original announcement bar code here -->
{% endif %}


Your updated announcement-bar.liquid might look like this:

 

{% if request.page_type == 'cart' %}
<div class="announcement-bar">
<!-- existing announcement bar HTML here -->
</div>
{% endif %}

 

If you will unable to implement the same then I'm happy to do this for you, let me know.

Hope this helps! If yes then Please don't forget hit Like and Mark it as solution!

 

If this is helpful, please Like and Accept the solution.
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me   

Buy Me A Coffee

amisha-29
Shopify Partner
93 1 23

It worked thankyou