Developer forum

Forum » Templates » Showing active variants

Showing active variants

Dennis Jacobsen
Reply

Hi

I've run into a bit of a problem. I can only get ALL variants to show, even though, i've deactivated some of them in the backend. Not all products will have the same variant options.

  
      <!--@LoopStart(VariantGroups)-->
      <select id="SelectVariantId" onchange="SetVariantOption(this)" class="form-control">
        <option selected="selected">V&aelig;lg Størrelse</option>
        <!--@LoopStart(VariantOptions)-->      
        <option value="<!--@Ecom:VariantOption.VariantID-->"><!--@Ecom:VariantOption.Name--></option>    
        <!--@LoopEnd(VariantOptions)-->
      </select>    
      <!--@LoopEnd(VariantGroups)--> 

 


Replies

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

Hi

I think you are looking for the VariantAvailableOptions sub loop

<!--@LoopStart(VariantGroups)-->
<select id="SelectVariantId" onchange="SetVariantOption(this)" class="form-control">
  <option selected="selected">V&aelig;lg Størrelse</option>
  <!--@LoopStart(VariantAvailableOptions)-->    
  <option value="<!--@Ecom:VariantOption.VariantID-->"><!--@Ecom:VariantOption.Name--></option>   
  <!--@LoopEnd(VariantAvailableOptions)-->
</select>   
<!--@LoopEnd(VariantGroups)-->

BR Nicolai

Votes for this answer: 1
 
Dennis Jacobsen
Reply

Exactly..! Thanks

 
Martin Christensen
Reply

I'm using the VariantAvailableOptions loop and I've got "Show only active variants" set in the management center. But somehow, a deactivated variant still shows up.

Any suggestions?

 
Nicolai Høeg Pedersen
Reply

Hi Martin

You have to ellaborate. How did you set the variant to deactivated? Can you provide a screen dump?

BR Nicolai

 
Martin Christensen
Reply

Of course - I select the product in quesion, and from the product-ribbon I click 'Variants'. Then edit a specific variant combination and mark it as 'Never active'.

http://i.imgur.com/Ym4GcUJ.png

 

 
Nicolai Høeg Pedersen
Reply

Hm, will have someone look into this. Will get back!

 
Oleg Rodionov
Reply

Hi all,

Dennis,

Please, use VariantCombinations loop instead. This loop allows to handle product variant rendering via "Show only active variants" setting. Refer to http://templates.dynamicweb.com/eCommerce/Dynamicweb-eCommerce-template-tags/Product-Catalog/Product-detail/Loops/VariantCombinations.aspx to find out tags available within the loop.

BR, Oleg QA

 
Martin Christensen
Reply

Hi Oleg,

thanks for the reply (also thanks to Nicolai) - The loop seems to produce exactly what I need in terms of active variants when I place a DwTemplateTags tag in it. However, it doesn't show up in the rendering. Instead it just outputs the following:

<!--@LoopOutput(VariantCombinations1)-->

Here's my code:

  <!--@LoopStart(VariantGroups)-->
    <div>
        <div><!--@Ecom:VariantGroup.Name--></div>
          <select class="sys-variant-select">
            <option value="0" selected>Select <!--@Ecom:VariantGroup.Name--></option>

            <!--@LoopStart(VariantCombinations)-->
              <!--@DwTemplateTags-->
                  <option value="<!--@Ecom:VariantCombination.VariantID-->"> <!--@Ecom:VariantCombination.VariantText--></option>
            <!--@LoopEnd(VariantCombinations)-->
          </select>
    </div>
  <!--@LoopEnd(VariantGroups)-->

 
Nicolai Høeg Pedersen
Reply

Hi Martin

You have the VariantCombinations inside the VariantGroups loop. That is not possible. It has to be in 2 different loops at the same level.

BR Nicolai

 

You must be logged in to post in the forum