Setting Product Option Defaults
Set product option defaults for your products
- Set default variant or option values for product
- Default to having no option selected for a product
- Limit a product to only show a specific variant within a source: product
- Ways to set product option defaults and limits
- Rules precedence
- Feature details & configuration instructions
Ways to set product option defaults and limits
- Set your product to default to the most common size everywhere it shows on the site
- Set your product to default to having no variant selected in order to force customers to select their size
- Create a link that defaults to a specific variant, so that traffic that clicks on an ad campaign is taken to the variant that was featured in the ad.
- Used in specific upsells or merchandising that highlight only one specific option for your product on a certain part of your site.
- If you want to override a global default in one specific location, for example for a one off campaign highlighting a certain colour or size that differs from the global default.
Rules Precedence
- Limiting to a specific variant within the Source Product (see more info)
- Set a product variant default via a URL Query String (see more info)
- Set a default product variant in the source product settings (see more info)
- Set default product option values via Shopify metafields (see more info)
- If none of the above are set, and the first variant is out of stock, then the product defaults to the first variant that is in stock.
- If none of the above are set and the first product is in stock, then the product defaults to the first variant listed in the Shopify product admin.
Setting Product Options Via Metafields
Note: Using global product option defaults with Sorting by price on collections might create an effect where the sort order appears broken depending on how you configure your price to display. Read here for more details.
In order to set product defaults via metafields:
- Add the following product metafields to your Shopify store with the namespace nyla_options and the keys defaultValue1, defaultValue2, defaultValue3. The values 1,2 and 3 correspond to the order of the product options in Shopify. Make sure that the metafields can be accessed through Storefront API. Shopify's official documentation for how to do this is accessible here.
- nyla_options.defaultValue1
- nyla_options.defaultValue2
- nyla_options.defaultValue3
- Add the value for each default product option for one or more products in your store (generally, if you're using this feature, you'd want to set it up for all products for consistency). The values should exactly match the name of the product option as it is exists in Shopify. (e.g. 34, Large or 12oz).
- In order to have your product option default to having no value selected, add false to the corresponding metafield (instead of a named value).
- If the value is left blank then no custom default value will be applied.
Note: Choosing having no option set to false will impact how your compare at pricing displays on your products and product grids. This is because the product.variant.compareAtPrice property will not be accessible given that no variant is selected.
In order to work around this, you can:
- If all the variants have the same compare-at-price, you can use product.variants.0.compareAtPrice instead, which will get the compare-at-price from the first variant.
- You can also use compareAtPrice in order to show a range of the compare at prices for the variants of your product.
For example, consider a Shopify product with the following options:
Specifying a product variant via a URL Query String
This feature enables your page to default to a specific product variant when a customer has clicked on a link containing the variant ID in the URL query string. The product variant is set directly after the page load.
A common use case for this method is to direct advertising traffic directly to a specific variant that has been featured in the campaign.
Configuration instructions:
To set this up, append a query string containing the Shopify variant ID onto your product page URL in this format: ?variant=variantID .
For example:
- Product page URL: https://mysite.com/products/my-product
- Should default to variant ID: 12345678910
- URL with query string: https://mysite.com/products/my-product?variant=12345678910
Note: This feature only works with product sources that are set to be a "PDP detail view". If your product page is using the page source, then this setting is set to on automatically, however if you are not referencing the page source, then you need to activate this setting inside the product source for this feature to work.
Tip: You can retrieve the ID of the Variant from the URL in the Shopify admin when viewing the variant, see screenshot below:

SEO considerations:
Limiting to a specific variant within the Source Product

Setting a default product variant in the Source Product settings
