Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi there,
I'm hoping to implement code to change the default variant selection on page load for this product page in the Dawn theme:
https://guisemen.com/products/green-stick?variant=47615513460969
Let me know how you would recommend going about this... you're guidance is GREATLY appreciated!
Best,
Will
This is a good one man. Will definitely try this out. Which product do you need to be selected on load the 3 pack or 6 pack?
Hi there! Thanks so much. Hoping to have the page default to the 3 pack on initial page load!
Hey Shadab, no stress if you haven't been able to, but I was curious whether you've had any success?
Hi @guisemen I did try man. But I guess it will take a bit more of looking up. I was able to load item of my choice but then selecting another didn't change anything.
But honestly this is a good one and I am up for it. Sorry to not update you and thank you for ringing a bell kind of a motivator.
Will update this time as it goes
Thanks
Shadab
No stress -- if this would take a substantial amount of work let me know and we can figure out a rate via email.
Hi will,
I kind of got a solution for it, not the best one I will say that it does have a gotcha but it does fulfill the purpose of the project which is to select a variant of our choice by default.
Let me explain how this works. So when you first enter the product page or when the page loads for which we need this feature what happens is Shopify's code is running and selecting the first available variant but I am refreshing the page again to change the variant to our selection. So the page kind of loads two times which might not be a big issue if your site speed is good and loads faster. So this happens on every load and by every load I mean every time user comes back to this specific product page the page loads twice with our choice of variant selected. Rest of the functionality works pretty fine like if user wants to select other variant and adding to cart, etc.
Just want to let you know how this is working before you throw a deal.
Please reach out via mail for a convenient conversation.
Thanks
Shadab Ali
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025