Re: How can I set default product variant on page load? (Dawn2.0)

How can I set default product variant on page load? (Dawn2.0)

jbk1
Excursionist
24 3 4

I have a product which has three variants. The option is `size`, and the three variants of this size option are `4`, `6` & `8`. On product page load the value of `product.selected_or_first_available_variant`  is set to the `4` variant, presumably because this is the first variants listed in the product variant's table in admin. I want the product to load on the `6` variant. But I do not want to change the order of the variants in the admin product variants table as this will have other undesired effects also (changing order of variant selector option values in UI).

 

How can I load this product so that it by default renders my `6` variant, as well as all of it's attributes (price, stock) and images etc?

Replies 9 (9)

LitExtension
Shopify Partner
4860 1002 1160

Hi @jbk1,

Do you want to customize it for a single product, or for all products?

And your product has only 1 option or will there be some with 2 options.

This is going to be a very complicated change so I need confirmation so I can give you the ultimate solution.

Hope it helps!

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
jbk1
Excursionist
24 3 4

Hi LitExtension,

 

I would like to be able to be able to select a default variant to show on product page load for all of my products which have an option and have variants. Currently some of my products have zero options, and the others have only 1 option (set size), this may change in future. For my products which do have an option, they only have that one option, and that one option has three variations (`4`, `6` & `8`).  Hope this helps clarify the cases.

 

Thanks in advance for your help.

LitExtension
Shopify Partner
4860 1002 1160

Hi @jbk1,

You can't choose the default variant to show on the product page, it will show the first variant.

If the values change in the future, this will not be possible. 

If the options are assigned static, you can create a new template for the products and reconfigure everything, but it will be difficult to detail.

Do you know about coding? You can use 'product.variants[1]' it will help you to call 2nd variants of product.

Hope it helps!

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
jbk1
Excursionist
24 3 4

ok, so just 'hardcode' the desired variant from the product.variants array then?

 

(yes, I can adjust the .liquid without too much difficulty)

LitExtension
Shopify Partner
4860 1002 1160

Hi @jbk1,

It's going to be a complicated tutorial with lots of steps, I can only suggest it for you.

- First, you need to create a new template for the products that need to display the 2nd variant

- For price you need to add condition by handle to show 2nd variant price. https://i.imgur.com/wEnK951.png

- For other information you need to check it in sections/main-product.liquid file and add conditions to everything.

Or if it's too complicated, I recommend you hire a professional, they will help you set everything up quickly. Refer https://community.shopify.com/c/Shopify-Ecommerce-Jobs/bd-p/shopify-job-board

If it helped you solve your issue, please mark it as a solution. Thank you and good luck.

 

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
timmycodes88
Shopify Partner
5 0 4

Also if you don't know coding -> You can re order the variants in the product settings and make sure the option you want as default is first. Heres a pic of my store so you know where you go to order them.

Screen Shot 2022-07-24 at 2.39.57 PM.png

Online_Seller
Shopify Partner
51 1 101

I've been wanting to do this too and it would be great if Shopify would introduce a default variant feature in the backend.

 

Example: Shopify Shop has T-shirts in Sizes S,M,L,XL,XXL.  If the customer clicks on a product, they will be presented with the first variant.  How many customers actually want a small T-shirt?  Almost any product that has sizes will have a somewhat Gaussian distribution to the sizes required, yet by ordering the variants by size means that any user that opens the product, and is presented with the first variant, will be presented with a variant which is in one of the tails of the distribution.  It makes very little sense and leads to problems.

dnorms
Visitor
1 0 0

Listen to this please. If the first variant (xtra-small) is out of stock the customer gets an immediate "Not Available" message when traveling from the thumbnail to the product page. It makes sense for xtra-small to be first on the size list, but not the default selection. Thank you.

Online_Seller
Shopify Partner
51 1 101

Hi,

 

While a default variant would get around your issue, if you are able and confident to edit the website code yourself, you can get around the specific issue that you have by using the following variable: selected_or_first_available_variant

 

Regards