Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Sticky Buy Now Button in Dawn Theme

Solved

Sticky Buy Now Button in Dawn Theme

MreenalChauhan
Tourist
7 0 2

Hi,

My website is mgrow.club.

Here is the link to my product page. I dont have Add to Cart option but direct Buy Now button. I want to add Sticky Buy Now button on the product page: https://mgrow.club/products/design-strategy-for-next-billion-users

How can it be done

Accepted Solutions (2)
Alok_Kasgar
Shopify Partner
112 26 28

This is an accepted solution.

Hi @MreenalChauhan 

 

May be jQuery library file missing. you c an add below code above the code that shared by me.

 

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

Alok Kasgar
If helpful, please Like and Accept this Solution to help others too | Email: alokasgar@gmail.com

View solution in original post

Alok_Kasgar
Shopify Partner
112 26 28

This is an accepted solution.

Update this code, It will work only on product page now

 

{% if template.name == 'product' %}

<style>
.shopify-payment-button__button.activebtn{
position: fixed;
bottom: 0px;
left: 0;
right: 0;
z-index: 999;
margin: auto;
max-width: 480px;
}
</style>


<script>
$(window).scroll(function() {
var scroll = $(window).scrollTop();

if (scroll >= 500) {
$(".shopify-payment-button__button").addClass("activebtn");
} else {
$(".shopify-payment-button__button").removeClass("activebtn");
}
});
</script>

{% endif %}

Alok Kasgar
If helpful, please Like and Accept this Solution to help others too | Email: alokasgar@gmail.com

View solution in original post

Replies 12 (12)

Alok_Kasgar
Shopify Partner
112 26 28

HI @MreenalChauhan 

 

I hope this solution will works. feel free to text me back if you have any question.
Please follow below steps
1) Go to Online Store
2) Edit Code
3) Find theme.liquid file
4) Add the following code in the bottom of the file above </body> tag

 

<style>
.shopify-payment-button__button{
position: fixed;
bottom: 0px;
left: 0;
right: 0;
z-index: 999;
margin: auto;
max-width: 480px;
}
</style>

Alok Kasgar
If helpful, please Like and Accept this Solution to help others too | Email: alokasgar@gmail.com

Alok_Kasgar
Shopify Partner
112 26 28

One More Alternate Option (button will sticky after scrolling down)

 

I hope this solution will works. feel free to text me back if you have any question.
Please follow below steps
1) Go to Online Store
2) Edit Code
3) Find theme.liquid file
4) Add the following code in the bottom of the file above </body> tag

 

<style>
.shopify-payment-button__button.activebtn{
position: fixed;
bottom: 0px;
left: 0;
right: 0;
z-index: 999;
margin: auto;
max-width: 480px;
}
</style>


<script>
$(window).scroll(function() {
var scroll = $(window).scrollTop();

if (scroll >= 500) {
$(".shopify-payment-button__button").addClass("activebtn");
} else {
$(".shopify-payment-button__button").removeClass("activebtn");
}
});
</script>

Alok Kasgar
If helpful, please Like and Accept this Solution to help others too | Email: alokasgar@gmail.com
MreenalChauhan
Tourist
7 0 2

Thanks Alok_Kasgar1. But none of the codes worked somehow. Am I missing something?

Alok_Kasgar
Shopify Partner
112 26 28

This is an accepted solution.

Hi @MreenalChauhan 

 

May be jQuery library file missing. you c an add below code above the code that shared by me.

 

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

Alok Kasgar
If helpful, please Like and Accept this Solution to help others too | Email: alokasgar@gmail.com
MreenalChauhan
Tourist
7 0 2

It worked perfectly. Thanks a ton..

MreenalChauhan
Tourist
7 0 2

Hey Alok,

Just one problem with this code. "Buy Now" sticky button is on the entire website including homepage, blog pages and not just on product page. Is there any way it can only be present on product page only.

Alok_Kasgar
Shopify Partner
112 26 28

This is an accepted solution.

Update this code, It will work only on product page now

 

{% if template.name == 'product' %}

<style>
.shopify-payment-button__button.activebtn{
position: fixed;
bottom: 0px;
left: 0;
right: 0;
z-index: 999;
margin: auto;
max-width: 480px;
}
</style>


<script>
$(window).scroll(function() {
var scroll = $(window).scrollTop();

if (scroll >= 500) {
$(".shopify-payment-button__button").addClass("activebtn");
} else {
$(".shopify-payment-button__button").removeClass("activebtn");
}
});
</script>

{% endif %}

Alok Kasgar
If helpful, please Like and Accept this Solution to help others too | Email: alokasgar@gmail.com
MreenalChauhan
Tourist
7 0 2

It worked. Thanks a lot

Ugurcan
Shopify Partner
348 7 34

Hi @MreenalChauhan;

If you are considering adding a Sticky button. We have a free Sticky Cart app that works on any theme. You can easily add it with the app and keep your code clean so you can upgrade to Dawn's newer versions easily later on.

Here is the app store link: https://apps.shopify.com/pasilobus-sticky-cart

We especially recommend not using Jquery or similar libraries which will drop your speed score.

Pasilobus | eCommerce Experts, Shopify Apps & Development since 2015 -- www.pasilobus.com
Stephen567
Tourist
28 0 2

Thanks for the instructions, but nothing here seemed to work for my Dawn store, based on checking using the Preview option. 

Ugurcan
Shopify Partner
348 7 34

@MreenalChauhan We recently released a sticky add-to-cart button app with a free plan. It works with all themes including Dawn, check it out: https://apps.shopify.com/pasilobus-sticky-cart

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

MRamzan
Shopify Partner
392 3 36

Sticky add to cart buttons feature you can add with this tutorial:

 

Hire Me:

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