Please help. I am looking to remove the auto variant selection from my theme. When a customer selects a product i don’t want a variant to already be selected - as below, the size and backing are auto selected when they click on the product. I have images linked to the size variants that i dont want to be the main product image.
To prevent the auto variant selection on your product pages, you can modify your theme’s JavaScript. Here’s what you’ll need to do:
Here’s what you’ll need to do:
Locate the Product Template:
-Open the product-template.liquid file in your theme’s code editor.
Find the Auto-Select Variant Script:
Search for a script that automatically selects the first variant when the page loads. This could look something like:
javascript
var firstVariant = product.variants[0];
selectVariant(firstVariant);
Disable Auto-Selection:
Remove or comment out the code that selects the first variant by default. This will stop the page from auto-selecting a variant when it loads:
// var firstVariant = product.variants[0];
// selectVariant(firstVariant);
Adjust or Disable Variant Image Change:
If there are scripts that change the product image based on the selected variant, you may also need to modify or disable this functionality to ensure the main image stays visible. Look for code that links variant selection to image changes and adjust accordingly.
If you encounter any issues or need help implementing this code, feel free to reach out to me via email—I’d be happy to assist you further. Thanks!
If my reply is helpful, kindly click like and mark it as an accepted solution.
Thanks!
Use our Big Bulk Discount app to boost your sales! (https://apps.shopify.com/big-bulk-discount). Easy to set up and perfect for attracting more customers with bulk discounts. Try it now and watch your revenue grow!