{* @compiler:inline-only *}

{if $product.sets}
   {foreach $product.sets as $set_product}
      {$set_product->fetchImages(2)}
      <div class="row product set" data-cart="row">
         <div class="product-image">
            <a title="{t}Zobrazit zboží{/t}" href="{url s=product IDproduct=$set_product.id TITLE=$set_product.title}">
               <img src="{get_photo photo=$set_product.image size=2}" alt="">
            </a>
         </div>
         <div class="product-title">
            <a title="{t}Zobrazit zboží{/t}"
               href="{url s=product IDproduct=$set_product.id TITLE=$set_product.title}">{$set_product.title}</a>
            <span>{t}set{/t}</span>
         </div>

         <div class="set-variations">
            {$variations = $set_product->fetchVariations(true)}

            {* Select first available or already selected one *}
            {if $product.note.set_variation[$set_product.id] > 0}
               {$id_selected = $product.note.set_variation[$set_product.id]}
            {/if}

            {foreach $variations.variations as $variation}
               {if $variation.in_store > 0}
                  <div class="radio">
                     <label>
                        <input type="radio" name="products[{$product.idincart}][note][set_variation][{$set_product.id}]"
                               value="{$variation.id}"
                               {if (!$id_selected and !$firstSelected) or $id_selected == $variation.id}checked{/if}>
                        {$firstSelected = true}
                        {foreach $variation.combinations as $index => $comb}
                           {assign var="il" value=$comb.id_label}
                           {assign var="iv" value=$comb.id_value}
                           {$variations.labels[$il].values[$iv]}
                        {/foreach}
                     </label>
                  </div>
               {/if}
            {/foreach}
         </div>
      </div>
   {/foreach}
{/if}
