{$gifts = $body->getPurchaseState()->getCustomData('gift')}
{$selected_products = []}
{foreach $gifts as $discountId => $selectedGifts}
    {$tmp_selected = array_filter(array_column($selectedGifts, 'id_product'))}
    {if $tmp_selected}
        {$selected_products = array_merge($selected_products, $tmp_selected)}
    {/if}
{/foreach}

{if $selected_products}
   {foreach $body->getPurchaseState()->getDiscountHandlers() as $handler}
      {$data = $handler->getData()}
      {* Pokud jsou varianty, `id_product` je id produktu a `gift` je id varianty.
         Bez variant je jen `gift` = id produktu. *}
      {$gift = $data['id_product']|default:$data['gift']}
      {if $gift and in_array($gift, $selected_products)}
         {$vars = $handler->getVars()}
         {$product = $vars['products'][$gift]}

         {if $product}
             {$image = 'product_gallery'}
             {$product->fetchImages($image)}
            <div class="cart-product-sets">
               <div class="set-item">
                  <div class="set-label">
                     <i class="fc icons_gift"></i>{$vars.title|default:"{t}Dárek k objednávce{/t}"}
                  </div>
                  <a href="{url s=product IDproduct=$product.id TITLE=$product.title}" title="{t}Zobrazit produkt{/t}">
                     <img src="{get_photo photo=$product.image size=4}" alt="{$product.title}"
                          class="img-responsive" width="{$cfg.Photo.types[$image].size[0]}" height="{$cfg.Photo.types[$image].size[1]}">
                  </a>
                  <a href="{url s=product IDproduct=$product.id TITLE=$product.title}" class="set-title">{$product.title}</a>
                  <div class="set-price">
                      {if $vars.price && $vars.price->getPriceWithVat()->isZero()}{t}zdarma{/t}{else}{$vars.price|format_price}{/if}
                  </div>
               </div>
            </div>
         {/if}
      {/if}
   {/foreach}
{/if}
