I’m trying to make a sticky add-to-cart button for my Shopify store without the use of any apps. I have done this so far by duplicating the current add-to-cart button and tweaking the CSS for the second button so it’s displayed at the bottom of my product page on top of all other elements. The only problem remaining is that both buttons are showing at the same time.
Right now I want to write an if-statement to handle which of the 2 buttons to show on the page based on if the default add-to-cart button is in or out of view for the user (so if the user has scrolled down past the button). Preferably I’d like a boolean to check weather the first button is in view so I can write an if/else statement to decide which button should be loaded but I’m not finding any solution for Liquid/Shopify coding.
Any tips on achieving this? I’m okay using JavaScript but having trouble implementing it with the Liquid code for my product page.
I’m using the Prestige theme.