Developer forum

Forum » Templates » "If statements" not working in Variants

"If statements" not working in Variants

George Nelzo Pereira
Reply

Hi, we are trying to use if statements in templates, but are not working or we are making wrong :)

<!--@LoopStart(VariantCombinations)-->
<!--@If(Ecom:Product.SelectedVariantComboID=Ecom:Product.VariantID)-->active<!--@Else-->No<!--@EndIf-->
<!--@LoopEnd(VariantCombinations)-->

Always they say is different.
But in pictures, you can see they have correct value, should be have at minimum one

http://www.screencast.com/t/bKuml8Ac1ETj

 


Replies

 
Nicolai Høeg Pedersen
Reply

I think the tags you are comparing might be in different scope.

You can use the @Ecom:VariantCombination.Product.Active tag instead. Does the same thing:

http://templates.dynamicweb.com/eCommerce/Dynamicweb-eCommerce-template-tags/Product-Catalog/Product-detail/Loops/VariantCombinations/EcomVariantCombination-Product-Active.aspx

Nicolai

 
George Nelzo Pereira
Reply

Hi...

Thanks for your reply.

I have a dropdown (select) with variant combination, than I need to select each one is selected (I mean each variant combinations is selected)

I try use your suggestion:

http://www.screencast.com/t/gvqrgzW4YeK

But they are given True from all combination...

How can I check which one is selected to set active in this dropdown?

 

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

Hi George

Sorry, wrong tag.

Like this:

<!--@LoopStart(VariantCombinations)-->
<!--@HeaderStart-->
<div id="productvariants">
 <select id="<!--@Ecom:VariantGroup.ID-->" name="<!--@Ecom:VariantGroup.Name-->" onchange="setVariant(this.options[this.selectedIndex].value);">
  <option>Select variant</option>
  <!--@HeaderEnd-->
  <option value="/<!--@Ecom:VariantCombination.LinkGroup.Clean-->"
   <!--@If Defined(Ecom:VariantCombination.Selected)--> selected="selected"<!--@EndIf(Ecom:VariantCombination.Selected)-->>
   <!--@Ecom:VariantCombination.VariantText-->
  </option>
  <!--@FooterStart-->
 </select>
</div>
<br />
<!--@FooterEnd-->
<!--@LoopEnd(VariantCombinations)-->
Votes for this answer: 1
 
George Nelzo Pereira
Reply

Thanks a lot

 

You must be logged in to post in the forum