<?php
/** @var \Magetop\Advancepreview\Block\PreviewMinicart $block */
$totalCart = $block->getTotalPriceInMiniCart();
//echo "TOTALAAL {$totalCart}";
$symobl = $block->getCurrentCurrencySymbol();
//echo $curency. 'Song dc bao lau';
$storeId = $block->getOpdStoreId();
?>
<?php if(isset($totalCart['is_custom']) && $totalCart['is_custom'] == 'yes') : ?>
<input type="hidden" id="txt-custom-minicart-total" value="<?php echo $totalCart['total_price']; ?>">
<input type="hidden" id="txt-custom-minicart-symobl" value="<?php echo trim($symobl); ?>">
<input type="hidden" id="txt-custom-minicart-store-id" value="<?php echo $storeId; ?>">
<script>
    require([
        'jquery'
    ],function ($) {

        var txtPrice = $('#txt-custom-minicart-total').val();
        var symobl = $('#txt-custom-minicart-symobl').val();
        // console.log("MINI clicjk ", txtPrice);
      /*  setTimeout(function () {
            $('.minicart-wrapper .total-mini-cart-price .price').html(txtPrice);
        },5000)*/
        var sec = 0;
        let conpareMiniPrice = symobl+'0.00';
        let storeId = $('#txt-custom-minicart-store-id').val();
        if(storeId === '1') {
            conpareMiniPrice = '0,00&nbsp;'+ symobl;
        }
        else if(storeId === '3') {
            conpareMiniPrice = symobl+'&nbsp;0.00';
        }
        var tiner = setInterval(function () {
            var qty = $('.total-mini-cart-price span').html();
            console.log(qty, conpareMiniPrice, sec)
            if(qty !== conpareMiniPrice) {
                $('.minicart-wrapper .total-mini-cart-price .price').html(txtPrice);
                clearInterval(tiner);
            }
            sec++;
        },500)
        setTimeout(function () {
            clearInterval(tiner);
        },11000)
        $('.minicart-wrapper .showcart').click(function () {
            console.log("testsete");
             $('#minicart-content-wrapper .block-content .price-wrapper > .price').html(txtPrice)
        })
        $('#top-cart-btn-checkout').click(function () {
            console.log("CLICK CLICK");
        })
    })
</script>
<?php endif; ?>
<?php $customerGroup = $block->getCustomerGroup(); ?>
<?php if($customerGroup < 2) : ?>
    <style>
        #block-collapsible-nav ul.items li:nth-child(3) {
            display: none;
        }

    </style>
<?php endif; ?>
