This page will show how to customize item variations. If you need item options instead, see this article: Modifying Item Options in a StoreFront
StoreFront Item Variations
This is no longer valid with the new visual builder storefronts. There is no need to edit or modify code directly and everything can now be configured within the element settings.
Helpful Links
Converting an Item from using Options to Variations (introduction to variations)
Item Variations (instructions for creating/configuring variations)
Adding ?uc-debug to then end of an item page containing variations will generate debugging output in the browser console.
Example: https://demo.ultracartstore.com/shop/TSHIRT.html**?uc-debug**
HTML Components
The variations are found in two places.
- The visible portions of the variations, such as the select boxes (or radio buttons), cost elements, and inventory spans or divs are found in the
**template_item.vm**file. - The javascript that powers the variations is (usually) found in the
**document_bottom.vm**file. This is a snippet file, so it is found in your/themes/<my theme name>/snippets/directory and NOT in the templates directory tree.
Item Variations Costs
Item costs may be automatically updated by following the following naming scheme. The javascript will search for matching elements and update their inner html with prices as they change with customer selections.
The javascript will also toggle the classes of cost and sale cost elements with 'has-sale' and 'no-sale' so you may stylize them as desired. For examples, search your main.css file in your theme for those two classes. You may also use event hooks (see below) to do just about anything you desire as cost changes.
#if($item.getMAPLocalized(false))
<span class="price uc-variation-cost-${item.getMerchantItemID()}">$item.getMAPLocalized(false)</span>
#elseif($item.getSaleCost())
<span class="#if($item.getSaleCost())has-sale#end price uc-variation-cost-${item.getMerchantItemID()}"><del>$item.getRegularCostLocalized()</del></span>
<span class="#if(!$item.getSaleCost())no-sale#end sale price uc-variation-sale-cost-${item.getMerchantItemID()}">$item.getSaleCostLocalized()</span>
#else
<span class="price uc-variation-cost-${item.getMerchantItemID()}">$item.getCostLocalized()</span>
#end
Item Variations Form Elements
#set($hasVariations = $item.getVariations().size() > 0)
#if($hasVariations)
#foreach($variation in $item.getVariations())
<label class="label-group"><span>${variation.getName()}</span>
<input type='hidden' name="VariationName${velocityCount}" value="${variation.getName()}" />
<select name="VariationValue${velocityCount}" id="uc-variation-field-${velocityCount}-${item.getMerchantItemID()}" class='variationSelectBox'>
</select>
</label>
#end
#end
This code is part of the much larger