{extends_parent}

{block "tpl-vars-gift" append}
    {$tpl_vars.gift_preselect_first = false} {* zaskrtnuti prvni moznosti pri prvnim prichodu do kosiku *}
{/block}

{block "gift-list"}
   <div class="cart-product-sets">
       {foreach $products as $product}
           {$product->fetchImages($tpl_vars.gift_img_size)}
           {$variations = $product->variations}
           {$gift_preselect = false}
           {if ($data.preselect_first == 1 || $tpl_vars.gift_preselect_first) && $frontend_data.gift === null && $product@first}
               {$gift_preselect = true}
           {/if}
          <div class="set-item" data-gift-item="{$id_action}">
             <input type="hidden" name="{$name}[gift]" value="0" data-gift-product>
              {if $variations}
                 <input type="hidden" name="{$name}[id_product]" value="{$product.id}" data-gift-product>
              {/if}

             <div class="set-label">
                 <i class="fc icons_gift"></i>{$title}
             </div>
             <img src="{get_photo photo=$product.image size=$tpl_vars.gift_img_size}" alt="{$discount.product.title}">
             <span class="set-title">
                 {$product.title}
             </span>

             <div class="set-price">
                 {if $tpl_vars.gift_show_free_price == true or $price->getPriceWithVat()->isPositive()}
                    <strong>{if $price->getPriceWithVat()->isZero()}{t}zdarma{/t}{else}{$price|format_price}{/if}</strong>
                 {/if}

                <div class="unwanted-gift">
                   <label class="custom-control custom-checkbox">
                      {if $variations}
                         {foreach $variations as $variation}
                            <input type="checkbox" name="{$name}[gift]" class="custom-control-input" value="{$variation.id}"
                                   {if $variation.id == $frontend_data.gift or ($gift_preselect and $variation@first)}checked{/if}>
                         {/foreach}
                      {else}
                         <input type="checkbox" name="{$name}[gift]" value="{$product.id}" class="custom-control-input" data-gift-product;
                                {if $frontend_data.gift == $product.id or $gift_preselect}checked{/if}>
                      {/if}
                      <span class="custom-control-indicator"></span>
                      {t}Chci dárek{/t}
                   </label>
                </div>
             </div>
          </div>
       {/foreach}
   </div>
{/block}
