Your IP : 13.58.114.163


Current Path : /home/bitrix/ext_www/xn--80atde5a3i.com/include/header/
Upload File :
Current File : /home/bitrix/ext_www/xn--80atde5a3i.com/include/header/top_cart.php

<?
//use Bitrix\Sale;
CModule::IncludeModule("iblock");
CModule::IncludeModule("sale");
CModule::IncludeModule("catalog");

$basket = \Bitrix\Sale\Basket::loadItemsForFUser(\Bitrix\Sale\Fuser::getId(), Bitrix\Main\Context::getCurrent()->getSite());

$price = $basket->getPrice(); // Сумма с учетом скидок

$basketList = $basket->getListOfFormatText();

$basketItems = $basket->getBasketItems();

$products = array();
foreach ($basketItems as $basketItem) {
    $arResult = CCatalogProduct::GetByIDEx($basketItem->getProductId());

    $imageUrl = "/src/images/products/product-1.jpg";

    if(is_array($arResult["PROPERTIES"]["MORE_PHOTO"]["VALUE"]))
        $imageUrl = CFile::GetPath($arResult["PROPERTIES"]["MORE_PHOTO"]["VALUE"][0]);
    else
        if($arResult["PROPERTIES"]["MORE_PHOTO"]["VALUE"])
            $imageUrl = CFile::GetPath($arResult["PROPERTIES"]["MORE_PHOTO"]["VALUE"]);

    if($arResult["PREVIEW_PICTURE"])
        $imageUrl = CFile::GetPath($arResult["PREVIEW_PICTURE"]);


    if($arResult["DETAIL_PICTURE"])
        $imageUrl = CFile::GetPath($arResult["DETAIL_PICTURE"]);

    $products [] = array(
        "ID"=>$basketItem->getProductId(),
        "NAME"=>$basketItem->getField('NAME'),
        "URL"=>$basketItem->getField('DETAIL_PAGE_URL'),
        "IMG"=>$imageUrl,
        "Q"=>$basketItem->getQuantity(),
        "PRICE"=>$basketItem->getFinalPrice(),);

//    pre($arResult);

}

//pre($products);
?>

<style>

    .show_cart {
            opacity: 1!important;
            -ms-transform: scaleY(1)!important;
            -webkit-transform: scaleY(1)!important;
            -moz-transform: scaleY(1)!important;
            -o-transform: scaleY(1)!important;
            transform: scaleY(1)!important;
        }
    }
</style>


<div id="cart_reload_block" class="top-cart-contain">
    <div class="mini-cart">
        <div data-toggle="dropdown" data-hover="dropdown" class="basket dropdown-toggle"><a
                    href="/personal/cart/">
                <div class="cart-icon"><i class="icon-basket-loaded icons"></i><span
                            class="cart-total"><?=count($products)?></span></div>
                <div class="shoppingcart-inner hidden-xs"><span
                            class="cart-title">Корзина</span></div>
            </a></div>
        <div>
            <div class="top-cart-content">
                <div class="block-subtitle hidden">Товары:</div>
                <ul id="cart-sidebar" class="mini-products-list">

                    <?foreach ($products as $product):?>
                    <li class="item odd"><a href="<?=$product["URL"]?>"
                                            title="<?=$product["NAME"]?>"
                                            class="product-image"><img
                                    src="<?=$product["IMG"]?>"
                                    alt="html Template" width="65"></a>
                        <div class="product-details"><a  hrefi="/ajax/basket.php?action=removeProd&productId=<?=$product["ID"]?>" title="Remove This Item"
                                                        class="remove-cart basket_delete"><i
                                        class="pe-7s-trash"></i></a>
                            <p class="product-name"><a  href="<?=$product["URL"]?>"><?=$product["NAME"]?></a></p>
                            <strong><?=$product["Q"]?></strong> x <span class="price"><?=$product["PRICE"]." "?>грн</span></div>
                    </li>
                    <?endforeach;?>

                </ul>
                <?if (count($products)==0):?>
                    <div class="top-subtotal">Ваша корзина пуста !<span class="price"><a href="/catalog/"> За покупками</a></span></div>
                    <?else:?>
                    <div class="top-subtotal">Всего: <span class="price"><?=$price?> грн</span></div>

                    <div class="actions">
                        <button class="btn-checkout" type="button"
                                onClick="location.href='/personal/order/make/'"><i
                                    class="fa fa-check"></i><span>Оформить</span></button>
                        <button class="view-cart" type="button"
                                onClick="location.href='/personal/cart/'"><i
                                    class="fa fa-shopping-cart"></i><span>Детальней</span>
                        </button>
                    </div>
                <?endif;?>
            </div>
        </div>
    </div>
</div>


<script>

    $(function() {
        $('body').on('click', '.basket_delete', function(){
            var url = $(this).attr("hrefi");
            $.get( url, function( data ) {
                reloadBasket();
            });
        });


        $('.top-cart-contain').hover(function () {
            hideCart();
        });
    });

    function showCart() {
        $('.top-cart-content').addClass("show_cart");
        $('body').scrollTo('.header-container',400);
    }

    function hideCart() {
        $('.top-cart-content').removeClass("show_cart");
    }

    function trogleCart() {
        $('.top-cart-content').toggleClass("show_cart");
    }

</script>