Jump to content

Set default variant?

Go to solution Solved by SpencerC,

Recommended Posts

  • 10 months later...
  • 3 months later...
On 8/12/2019 at 10:48 PM, LagoVistaFilmLab said:

I would love to set the default variant

You can set the default variant on each product using our Variant Pricing extension.

variant-pricing-tile.thumb.png.a2c98ef27e29d4a50e3183ff16f5f031.png

Our extension preselects the first option in every variant dropdown so that customers can quickly purchase the default variant. Do contact me if you have questions or want to purchase something more bespoke.

-Paul

About: SQSP User for 17 yrs. Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥.
Work: Founder of SF Digital, building Squarespace Extensions to supercharge your commerce website. 
Content: Links in my posts may refer to SF Digital products or may be affiliate links.
If my advice helped, you can thank me by clicking one of the feedback emojis below. I love coffee too.

Link to comment
  • 2 years later...

You don't need to pay for an app: use this code

<script>

function setValue() 
  
{
     var dropdown = document.querySelectorAll('[data-variant-option-name="Type"]')[0];
    dropdown.value = 'Summer Flap';
    Y.one(dropdown).simulate('change');
  
  var dropdown2 = document.querySelectorAll('[data-variant-option-name="Colour"]')[0];
    dropdown2.value = 'Orange $89';
    Y.one(dropdown).simulate('change');
  
}
  
  window.onload = setValue;

</script>

Link to comment
  • 1 month later...
<script>
function setValue() {
document.querySelectorAll('div.variant-option select').forEach(function(dropdown){
  dropdown.selectedIndex = '1';
  Y.one(dropdown).simulate('change');
});
}
 window.onload = setValue ;
</script>

The above code can put in `Page Header Code Injection` and it will select the first variant option and displays its price as well

I modified @DomBrady answer to work with any product variant without having to specify variant details in code

Edited by AshAb
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.