How can I add a scroll function to my sticky add to cart bar?

Solved

How can I add a scroll function to my sticky add to cart bar?

Grace_01
Shopify Partner
91 3 13

I have sticky add to cart bar and want to scroll function to it. Need help to add below js code like where to add in global.js to get exact scroll function so that sticky add to cart bar will only appear after scroll. Using shopify 2.0 dawn theme.

Store Link

$(window).scroll(function (event) {
    var height = $(window).height();
    var scroll = $(window).scrollTop();
    //console.log(scroll + " " + height);
    if(scroll > height){
     $(".sticky_cart").addClass("show");
    } else {
     $(".sticky_cart").removeClass("show");
    }
  });
  
  $("#btn-sticky-cart").click(function(){
  	$(".paymentButtonsWrapper #AddToCart").click();
  });

 

 

Accepted Solution (1)
Ahsan_ANC
Shopify Partner
1396 253 326

This is an accepted solution.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

 

download (9).png

Contact for any custom design? Skype : ahsananc
>Was your question answered? Mark it as an Accepted Solution!
Feel Free to Contact Me at my Email: anc2277@gmail.com


To enhance and customize Shopify search and filter, I use Boost Product Filter & Search

View solution in original post

Replies 14 (14)

Ahsan_ANC
Shopify Partner
1396 253 326

you should put this code at the very bottom of your gobal.js file. So it will be handy to find and change it later.

Contact for any custom design? Skype : ahsananc
>Was your question answered? Mark it as an Accepted Solution!
Feel Free to Contact Me at my Email: anc2277@gmail.com


To enhance and customize Shopify search and filter, I use Boost Product Filter & Search
Grace_01
Shopify Partner
91 3 13

@Ahsan_ANC I have added but it's not working

Ahsan_ANC
Shopify Partner
1396 253 326

where you have added the code. there is not code in your theme global.js file

 

https://cdn.shopify.com/s/files/1/0337/3737/5879/t/37/assets/global.js

Contact for any custom design? Skype : ahsananc
>Was your question answered? Mark it as an Accepted Solution!
Feel Free to Contact Me at my Email: anc2277@gmail.com


To enhance and customize Shopify search and filter, I use Boost Product Filter & Search
Grace_01
Shopify Partner
91 3 13

@Ahsan_ANC Added again

Ahsan_ANC
Shopify Partner
1396 253 326

plz also add jquery to your theme 

Contact for any custom design? Skype : ahsananc
>Was your question answered? Mark it as an Accepted Solution!
Feel Free to Contact Me at my Email: anc2277@gmail.com


To enhance and customize Shopify search and filter, I use Boost Product Filter & Search
Ahsan_ANC
Shopify Partner
1396 253 326

This is an accepted solution.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

 

download (9).png

Contact for any custom design? Skype : ahsananc
>Was your question answered? Mark it as an Accepted Solution!
Feel Free to Contact Me at my Email: anc2277@gmail.com


To enhance and customize Shopify search and filter, I use Boost Product Filter & Search
Grace_01
Shopify Partner
91 3 13

@Ahsan_ANC Thanks, working prefect now

Ahsan_ANC
Shopify Partner
1396 253 326

that's nice!

 

one more thing the product image overlaps the bar plz add the following code at the bottom of "base.css"

 

.sticky_cart{
    z-index: 99999;
}
Contact for any custom design? Skype : ahsananc
>Was your question answered? Mark it as an Accepted Solution!
Feel Free to Contact Me at my Email: anc2277@gmail.com


To enhance and customize Shopify search and filter, I use Boost Product Filter & Search
Grace_01
Shopify Partner
91 3 13

@Ahsan_ANC but after this code whatsapp button overlapped now

Ahsan_ANC
Shopify Partner
1396 253 326

plz replace 99999 with just 99

 

and also one more thing

.sticky_cart{
z-index: 99;
padding-right: 110px;
}
Contact for any custom design? Skype : ahsananc
>Was your question answered? Mark it as an Accepted Solution!
Feel Free to Contact Me at my Email: anc2277@gmail.com


To enhance and customize Shopify search and filter, I use Boost Product Filter & Search
Grace_01
Shopify Partner
91 3 13

@Ahsan_ANC Now it's prefect aligned, Thanks again 

Ahsan_ANC
Shopify Partner
1396 253 326

plz share the store URL.

Contact for any custom design? Skype : ahsananc
>Was your question answered? Mark it as an Accepted Solution!
Feel Free to Contact Me at my Email: anc2277@gmail.com


To enhance and customize Shopify search and filter, I use Boost Product Filter & Search

Ugurcan
Shopify Partner
348 7 34

We now offer a sticky cart solution with a free plan. It works with all themes, check it out: https://apps.shopify.com/pasilobus-sticky-cart

Pasilobus | eCommerce Experts, Shopify Apps & Development since 2015 -- www.pasilobus.com

MRamzan
Shopify Partner
213 3 31

Here is the solution to add sticky add to cart bar in your store:

 

Hire Me:

WhatsApp: +91-9145985880
Email: mohdramzaan112@gmail.com
Skype: mohdramzaan112