How to sticky overlay the buy buttons on this product page?

Solved

How to sticky overlay the buy buttons on this product page?

empiricalarby
Trailblazer
230 1 52

https://empiricalwater.com/products/starter-kit

Dawn theme.

Screenshot 2024-07-28 012439.png

It would be pretty ideal to get this working on both desktop and mobile. Cheers

Accepted Solutions (3)

BSSCommerce-HDL
Shopify Partner
2305 834 905

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

View solution in original post

BSS-TekLabs
Shopify Partner
2401 695 827

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

BSSTekLabs_0-1722157713979.png

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


BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now

View solution in original post

BSS-TekLabs
Shopify Partner
2401 695 827

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

BSSTekLabs_0-1722264886127.png

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


BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now

View solution in original post

Replies 10 (10)

BSSCommerce-HDL
Shopify Partner
2305 834 905

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

empiricalarby
Trailblazer
230 1 52

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.

Screenshot 2024-07-28 020508.png

BSS-TekLabs
Shopify Partner
2401 695 827

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

BSSTekLabs_0-1722157713979.png

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


BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now
empiricalarby
Trailblazer
230 1 52

Nicely done!

BSS-TekLabs
Shopify Partner
2401 695 827

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


BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now
empiricalarby
Trailblazer
230 1 52

Just noticed something, are you able to remove this white space to save space on the screen?

Screenshot 2024-07-28 023743.png

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:

Screenshot 2024-07-28 024114.png

BSS-TekLabs
Shopify Partner
2401 695 827

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


BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now
empiricalarby
Trailblazer
230 1 52

Weirdly enough, the buy button isn't sticky anymore. Any idea what's causing that?

https://empiricalwater.com/products/starter-kit

 

BSS-TekLabs
Shopify Partner
2401 695 827

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

BSSTekLabs_0-1722264886127.png

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


BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now
empiricalarby
Trailblazer
230 1 52

PERFECTION!!