Resources
Please use the following links to get a visual on how dynamic variants will be setup:
Instructions
- Add a single line plain text field for each variant group (ex: Colors, Sizes, etc.)
- 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.
- To have a variant option modify the price, weight, code, or category, add a valid product option modifier to that option or options.
- In Webflow's Designer, go to your Products Collection Template (this may be called something else in your project).
- Give your add to cart Form a class name (ex: product-form). This class name will be used in a future step.
- Add a select field (and optionally a label) for each variant group.
- Give each select field a a unique class name (ex: colors).
- 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).
- 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.
- Right inside your add to cart Form Block, add an HTML Embed element.
- Inside of the HTML Embed element, copy/paste the snippet from here.
- 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.
- On line 4, replace
SELECT CLASS NAME
with the class name of your first variant group (ex: colors).
- On line 4, replace
CMS FIELD
with the corresponding CMS field for your first variant group.
- For each additional variant group, copy/paste line 4, modify the class name, and change the CMS field.
- In your Products Template Settings, copy/paste the snippet from here into the "Before </body> tag" section.
- 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.
- Give your price display element a class name of "product_total".
- Select your add to cart Form (ex: product-form) and go to the Element Settings Panel.
- With the form selected, add a custom attribute with the Name "data-fc-form-code" and Value "product".
- 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.
- In your Products CMS Collection, add a multi-image field.
- Upload your images and sort them in the same order of your variant options (ex: Colors)
- In your Products Template, anywhere on the page, add a Collection List element.
- In the Collection List element Settings, set the Source as your new multi-image field.
- For each Collection List item, add an Image element and connect it to the CMS image.
- Give the Collection List Wrapper an ID of "foxy-images".
- Visually hide the Collection List.
- Give your main product image an ID of "foxy-image".
- In your Products Template Settings "Before </body> tag" section, copy/paste the snippet from here, right after:
- Replace CHANGE with the class name of the variant select field you want to trigger the image change (ex: "colors").
- 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}
Valid Options
p | Modifies: Price |
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. |