{extends_parent}

{block "products-price"}
    {$sapData = $body->getData('sap')}

   {* Always display products price *}
   {if true}
       <div class="price-box-row">
          <p>{t}Cena zboží{/t}</p>
          <p>
              {$discountsProductsTotalPrice = $body->getPurchaseState()->discountsProductsTotalPrice}
              {* discountsProducts - napr. darky, jsou vetsinou zdarma, ale mohou byt i za nejakou cenu *}
              {* cena darku neni zapoctena v totalPrice *}
              {$productsTotalPriceIncrement = 0}
              {if $discountsProductsTotalPrice}
                  {if $noVat}
                      {$productsTotalPriceIncrement = $discountsProductsTotalPrice->getPriceWithoutVat()}
                  {else}
                      {$productsTotalPriceIncrement = $discountsProductsTotalPrice->getPriceWithVat()}
                  {/if}
              {/if}

              {* Custom vec - odecteme SAP slevy z ceny produktu, aby cena zbozi byla pred slevou a nasledne pod tim zobrazime jednotlive slevy  *}
              {$customDiscounts = toDecimal(0)}
              {foreach $sapData.discounts as $discount}
                  {$customDiscounts = $customDiscounts->add($discount.price)}
              {/foreach}


              {if $noVat}
                  {$productsTotalPrice->getPriceWithoutVat()->add($productsTotalPriceIncrement)->add($customDiscounts)|format_price}
              {else}
                  {$productsTotalPrice->getPriceWithVat()->add($productsTotalPriceIncrement)->add($customDiscounts)|format_price}
              {/if}
          </p>
       </div>
    {/if}

    {* Render SAP discounts - zobrazení *}
    {foreach $sapData.discounts as $discount}
       <div class="price-box-row discount">
          <p>{$discount.name}</p>
          <p>{$discount.price->mul(toDecimal(-1))|format_price}</p>
       </div>
    {/foreach}
{/block}

{block "pricebox-transport"}
   {if $transport==1}
      <div class="price-box-row">
         {if !$body.transport}
            <p>
               {if !$body.delivery_id}{t}Vyberte dopravu{/t}{else}{t}Vyberte platbu{/t}{/if}
            </p>
         {else}
            <p>{t}Doprava a platba{/t}</p>
            <p>
               {$delivery = $body->getDeliveryType()}
               {if $delivery.price.value_without_vat->isPositive()}
                  {if $noVat}{$delivery.price.value_without_vat|format_price}{else}{$delivery.price.value_with_vat|format_price}{/if}
               {else}
                  {t}zdarma{/t}
               {/if}
            </p>
         {/if}
      </div>
   {/if}
{/block}

{block "pricebox-total" prepend}
   {get_cart_savings assign='cartSavings'}
   {if $cartSavings->isPositive()}
      <div class="price-box-row total-price total-discount">
         <p>{t}Ušetříš{/t}</p>
         <p>{$cartSavings|format_price}</p>
      </div>
   {/if}
{/block}
