<? if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) die();

$this->IncludeLangFile('template.php');

$cartId = $arParams['cartId'];

require(realpath(__DIR__) . '/top_template.php');

if ($arParams["SHOW_PRODUCTS"] == "Y" && ($arResult['NUM_PRODUCTS'] > 0 || !empty($arResult['CATEGORIES']['DELAY']))) {
    ?>
    <div data-role="basket-item-list" class="header_cart_list">


        <div id="<?= $cartId ?>products">

            <? foreach ($arResult["CATEGORIES"] as $category => $items):
                if (empty($items))
                    continue;
                ?>


                <? foreach ($items as $v): ?>
                <div class="header_cart_item">

                    <a href="<?= $v["DETAIL_PAGE_URL"] ?>">
                        <span class="header_cart_item_pict"
                              style="background-image: url(<?= $v["PICTURE_SRC"] ?>);"></span>
                        <strong class="header_cart_item_name">
                            <?= $v["NAME"] ?>  <?= $v["QUANTITY"] ?> <?= $v["MEASURE_NAME"] ?>
                            <span class="header_cart_item_price">
                                 <? if ($v["FULL_PRICE"] != $v["PRICE_FMT"]): ?>
                                     <del><?= $v["FULL_PRICE"] ?></del>
                                 <? endif ?>
                                    <?= $v["PRICE_FMT"] ?>
                            </span>
                        </strong>

                        <span class="header_cart_item_summ">
                             на <?= $v["SUM"] ?>
                        </span>
                    </a>
                    <button onclick="<?= $cartId ?>.removeItemFromCart(<?= $v['ID'] ?>)">
                        x
                    </button>
                </div>
            <? endforeach ?>
            <? endforeach ?>
        </div>

        <div class="header_cart_list_footer">
            <span>Итого: <?=$arResult['TOTAL_PRICE']?></span>
            <a href="<?= $arParams["PATH_TO_ORDER"] ?>"><?= GetMessage("TSB1_2ORDER") ?></a>
        </div>
    </div>

    <script>
        BX.ready(function () {
            <?=$cartId?>.fixCart();
        });
    </script>
    <?
}