Manage product variants with Webflow CMS

Use Webflow CMS to dynamically control what variant groups and options are available for your products.

Note

This article assumes you have already setup your Products CMS Collection and add to cart forms. More information here. Also, this approach does not work with our Webflow CMS inventory integration. If you need to automatically update inventory counts for variants, please contact us.

Resources

Please use the following links to get a visual on how dynamic variants will be setup:

Instructions

  1. Add a single line plain text field for each variant group (ex: Colors, Sizes, etc.)       

  2. For each product, add a comma separated list of values for each variant group. Simply leave a variant group field blank if no options are available.       

  3. To have a variant option modify the price, weight, code, or category, add a valid product option modifier to that option or options.       

  4. In Webflow's Designer, go to your Products Collection Template (this may be called something else in your project).
  5. Give your add to cart Form a class name (ex: product-form). This class name will be used in a future step.       

  6. Add a select field (and optionally a label) for each variant group.       

  7. Give each select field a a unique class name (ex: colors).       

  8. Give each select field a Name (ex: Color). This label will show in the cart. If your Name has spaces, use an underscore instead of a space (ex: Primary_Color).       

  9. Remove all select field choices. Alternatively, you can leave the first choice as a label. If you do this, you'll want to set the value as empty and make the select field required.       

  10. Right inside your add to cart Form Block, add an HTML Embed element.       

  11. Inside of the HTML Embed element, copy/paste the snippet from here.  
  12. In the snippet, replace each FORM CLASS NAME (on line 3 & 4) with the class name you gave your add to cart Form (ex: product-form) in Step 5.       

    Please note that Webflow exports class names as lowercase, even if you use uppercase letters in the Designer. So be sure to input your form class name as all lowercase letters.       

  13. On line 4, replace SELECT CLASS NAME with the class name of your first variant group (ex: colors).       

  14. On line 4, replace CMS FIELD with the corresponding CMS field for your first variant group.       

  15. For each additional variant group, copy/paste line 4, modify the class name, and change the CMS field.       

  16. In your Products Template Settings, copy/paste the snippet from here into the "Before </body> tag" section.    
  17. Publish and test.

Conditionally Show/Hide Variants

To conditionally show/hide variant select fields, simply add a conditional visibility setting to the select field and corresponding label:

Real-time Price Display

By default, your price display will not change based on chosen variants and quantity. Please follow the instructions below to display the updated price in real-time.

  1. Give your price display element a class name of "product_total".       

  2. Select your add to cart Form (ex: product-form) and go to the Element Settings Panel.
  3. With the form selected, add a custom attribute with the Name "data-fc-form-code" and Value "product".       

  4. In your Products Template Settings, copy/paste the snippet from here into the "Before </body> tag" section (after any existing code). If you've hit Webflow's 10k character limit, you can add this snippet to your Webflow > Project Settings > Custom Code > Footer (after any existing code).

Real-time Image Change

There may be times where you want to change the displayed image (and image that's passed to the cart) based on a chosen variant. Please follow the instructions below to do this. These instructions are for one variant. If you have a combination of variants that determine the displayed image, please contact us.

  1. In your Products CMS Collection, add a multi-image field.
  2. Upload your images and sort them in the same order of your variant options (ex: Colors)
  3. In your Products Template, anywhere on the page, add a Collection List element.
  4. In the Collection List element Settings, set the Source as your new multi-image field.
  5. For each Collection List item, add an Image element and connect it to the CMS image.
  6. Give the Collection List Wrapper an ID of "foxy-images".
  7. Visually hide the Collection List.
  8. Give your main product image an ID of "foxy-image".
  9. In your Products Template Settings "Before </body> tag" section, copy/paste the snippet from here, right after:
  10.  
  11. Replace CHANGE with the class name of the variant select field you want to trigger the image change (ex: "colors").
  12. Publish and test.   
     

Optional Settings

By default, USD will be used for the currency. In addition, a summary will be displayed if a variant option affects the price (ex: +$5). These settings can be modified in your Products Template Settings > "Before </body> tag" section:

var currency_symbol = '$';
var modifier_text_summary = true;


Product Option Modifiers

Product option modifiers allow you to modify the price, weight, code, or category when another option is set. Modifiers are placed inside curly brackets {} at the end of your product option, and can add to +, subtract from -, or set : new values to the modified option. Multiple modifiers can be chained together with the “pipe” symbol |

Example

{p+1.50|w-1|c:01a|y:teeny_category} 

Note

If you're working with a product code modifier, be sure your code input comes before your product option that modifies it. Modifiers cannot be applied to standard product options (ex: price or name).

Valid Options

p

Modifies: Price       
Increasing: Small{p+5}       
Decreasing: Small{p-5}       
Setting: Small{p:5}       
Notes: If working with multicurrency, you may need to append the currency code to the price as required, such as {p+5CAD}. If no currency code is specified, it's assumed the price is in the store currency.

w Modifies: Weight.       
Increasing: Small{w+5}       
Decreasing: Small{w-5}       
Setting: Small{w:5}
c Modifies: Code       
Setting:  Small{c:bar} would yield a code of "bar".       
Appending: Small{c+bar} would add "bar" to your product base code and any other code modifier options
y Modifies: Category       
Setting: Small{y:bar} would yield a category of "bar".       
Notes: This can be especially handy in donation forms that allow both single and recurring donations.

In This Article

Related Articles

Create a purchase form with Webflow's Form Builder
Getting Started with Foxy + Webflow
Create a purchase button in Webflow
Manage product inventory with Webflow's CMS

Need help?

Can't find the answers you're looking for? Our team is here to help. Please click below to contact us.

Contact Us