Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
https://empiricalwater.com/products/starter-kit
Dawn theme.
It would be pretty ideal to get this working on both desktop and mobile. Cheers
Solved! Go to the solution
This is an accepted solution.
Hi @empiricalarby ,
Step 1: Go to Shopify Admin -> Online Store ->Theme -> Edit code
Step 2: Search file theme.liquid
Step 3: Insert this code above </head> tag:
{% assign full_url = request.host | append: request.path %}
{% if full_url contains '/products/starter-kit' %}
<style>
div:has(.product-form) {
position: sticky !important;
top: 10px;
}
</style>
{% endif %}
Hope this can help you,
If our suggestions are useful, please let us know by giving it a like or marking it as a solution. Thank you 😍
Sale banner, pop ups: Customize your sale banner, pop-ups and create countdown bar to boost conversion rate.
Simicart: Transform your Shopify store into a stunning and fully functional mobile app with just a few simple steps.
Product Labels & Badges: Get more sales with striking labels, badges, and banners from our 10,000+ available templates.
BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now
This is an accepted solution.
Hi @empiricalarby,
Here are the steps you can follow:
1, Navigate to Online Store > Themes > Edit Code.
2, Locate and open the theme.liquid file.
3, Paste the code snippet provided below right before the closing head tag, then save your changes.
<script>
document.addEventListener("DOMContentLoaded", () => {
const targetURLs = [
"https://empiricalwater.com/products/starter-kit",
];
if (targetURLs.some(url => window.location.href.includes(url))) {
const style = document.createElement('style');
style.textContent = `
#ProductInfo-template--18120489337083__main > div:nth-child(5) {
background: #fff;
position: sticky;
top: 0;
padding-top: 1px;
}
`;
document.head.appendChild(style);
}
});
</script>
Here is the result
We hope this assists in resolving the issue.
If you find our solution helpful, kindly consider Liking and Marking it as Accepted. Thank you!
If our suggestions are useful, please let us know by giving it a like or marking it as a solution.
Salepify: Efficiently increase sales conversion with sale-driven features like auto add to cart, free gifts (free plan available)
Salemate: Boost your AVO with 2-layer offer, countdown upsell in your post purchase page
This is an accepted solution.
Hi there, maybe the HTML structure has changed a bit so the selector above didn't work anymore. But here is the updated code for you
<script>
document.addEventListener("DOMContentLoaded", () => {
const targetURLs = [
"https://empiricalwater.com/products/starter-kit",
];
if (targetURLs.some(url => window.location.href.includes(url))) {
const style = document.createElement('style');
style.textContent = `
div:has(.product-form) {
background: #fff;
position: sticky;
top: 0;
padding-top: 0;
z-index: 999;
}
`;
document.head.appendChild(style);
}
});
</script>
Here the buy button is sticky again
We hope this assists in resolving the issue.
If you find our solution helpful, kindly consider Liking and Marking it as Accepted. Thank you!
If our suggestions are useful, please let us know by giving it a like or marking it as a solution.
Salepify: Efficiently increase sales conversion with sale-driven features like auto add to cart, free gifts (free plan available)
Salemate: Boost your AVO with 2-layer offer, countdown upsell in your post purchase page
This is an accepted solution.
Hi @empiricalarby ,
Step 1: Go to Shopify Admin -> Online Store ->Theme -> Edit code
Step 2: Search file theme.liquid
Step 3: Insert this code above </head> tag:
{% assign full_url = request.host | append: request.path %}
{% if full_url contains '/products/starter-kit' %}
<style>
div:has(.product-form) {
position: sticky !important;
top: 10px;
}
</style>
{% endif %}
Hope this can help you,
If our suggestions are useful, please let us know by giving it a like or marking it as a solution. Thank you 😍
Sale banner, pop ups: Customize your sale banner, pop-ups and create countdown bar to boost conversion rate.
Simicart: Transform your Shopify store into a stunning and fully functional mobile app with just a few simple steps.
Product Labels & Badges: Get more sales with striking labels, badges, and banners from our 10,000+ available templates.
BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now
Wow, that was incredibly quick! This is really nice! Are you able to give the area above the dynamic button a white background to avoid clashing with the text?
I'm referring to this area, including under the "only X left" text.
This is an accepted solution.
Hi @empiricalarby,
Here are the steps you can follow:
1, Navigate to Online Store > Themes > Edit Code.
2, Locate and open the theme.liquid file.
3, Paste the code snippet provided below right before the closing head tag, then save your changes.
<script>
document.addEventListener("DOMContentLoaded", () => {
const targetURLs = [
"https://empiricalwater.com/products/starter-kit",
];
if (targetURLs.some(url => window.location.href.includes(url))) {
const style = document.createElement('style');
style.textContent = `
#ProductInfo-template--18120489337083__main > div:nth-child(5) {
background: #fff;
position: sticky;
top: 0;
padding-top: 1px;
}
`;
document.head.appendChild(style);
}
});
</script>
Here is the result
We hope this assists in resolving the issue.
If you find our solution helpful, kindly consider Liking and Marking it as Accepted. Thank you!
If our suggestions are useful, please let us know by giving it a like or marking it as a solution.
Salepify: Efficiently increase sales conversion with sale-driven features like auto add to cart, free gifts (free plan available)
Salemate: Boost your AVO with 2-layer offer, countdown upsell in your post purchase page
Nicely done!
You're welcome! 😊
If our suggestions are useful, please let us know by giving it a like or marking it as a solution.
Salepify: Efficiently increase sales conversion with sale-driven features like auto add to cart, free gifts (free plan available)
Salemate: Boost your AVO with 2-layer offer, countdown upsell in your post purchase page
Just noticed something, are you able to remove this white space to save space on the screen?
It would help a lot, especially on mobile. Also please refer to the screenshot above: That's the perfect position where the button should stop, instead of how it is now:
Please replace the previous code snippet with this code snippet. The styling has been updated.
<script>
document.addEventListener("DOMContentLoaded", () => {
const targetURLs = [
"https://empiricalwater.com/products/starter-kit",
];
if (targetURLs.some(url => window.location.href.includes(url))) {
const style = document.createElement('style');
style.textContent = `
#ProductInfo-template--18120489337083__main > div:nth-child(5) {
background: #fff;
position: sticky;
top: 0;
padding-top: 0;
z-index: 999;
}
`;
document.head.appendChild(style);
}
});
</script>
In the second image, the button was overlapped by the text because of its z-index, I've fixed that in the CSS style above!
If our suggestions are useful, please let us know by giving it a like or marking it as a solution.
Salepify: Efficiently increase sales conversion with sale-driven features like auto add to cart, free gifts (free plan available)
Salemate: Boost your AVO with 2-layer offer, countdown upsell in your post purchase page
Weirdly enough, the buy button isn't sticky anymore. Any idea what's causing that?
https://empiricalwater.com/products/starter-kit
This is an accepted solution.
Hi there, maybe the HTML structure has changed a bit so the selector above didn't work anymore. But here is the updated code for you
<script>
document.addEventListener("DOMContentLoaded", () => {
const targetURLs = [
"https://empiricalwater.com/products/starter-kit",
];
if (targetURLs.some(url => window.location.href.includes(url))) {
const style = document.createElement('style');
style.textContent = `
div:has(.product-form) {
background: #fff;
position: sticky;
top: 0;
padding-top: 0;
z-index: 999;
}
`;
document.head.appendChild(style);
}
});
</script>
Here the buy button is sticky again
We hope this assists in resolving the issue.
If you find our solution helpful, kindly consider Liking and Marking it as Accepted. Thank you!
If our suggestions are useful, please let us know by giving it a like or marking it as a solution.
Salepify: Efficiently increase sales conversion with sale-driven features like auto add to cart, free gifts (free plan available)
Salemate: Boost your AVO with 2-layer offer, countdown upsell in your post purchase page
PERFECTION!!
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024