<!-- HEADER AREA START (header-3) -->
<header class="ltn__header-area ltn__header-3 section-bg-6">
    <!-- ltn__header-middle-area start -->
    <div class="ltn__header-middle-area">
        <div class="container">
            <div class="row">
                <div class="col">
                    <div class="site-logo">
                        <a href="/"><img src="{{'assets/logo_n.svg'|theme}}" alt="Nurgul" style="width: 80%;"></a>
                    </div>
                </div>
                <div class="col header-contact-serarch-column d-none d-xl-block">
                    <div class="header-contact-search">
                        <!-- header-feature-item -->
                        <div class="header-feature-item">
                            <div class="header-feature-icon">
                                <i class="icon-phone"></i>
                            </div>
                            <div class="header-feature-info">
                                <h6>{{'phone.title'|_}}</h6>
                                <p><a href="tel:{{'phone.number'|_}}">+{{'phone.number'|_}}</a></p>
                            </div>
                        </div>
                        <!-- header-search-2 -->
                        <div class="header-search-2">
                            <form id="#searchForm" method="post" action="/search">
                                <input type="text" name="keyword" value="" placeholder="{{'search'|_}}..." />
                                <button type="submit">
                                    <span><i class="icon-magnifier"></i></span>
                                </button>
                            </form>
                        </div>
                    </div>
                </div>
                <div class="col">
                    <!-- header-options -->
                    <div class="ltn__header-options">
                        <ul>

                            <li class="">
                                <!-- user-menu -->
                                <div class="ltn__drop-menu user-menu">
                                    <ul>
                                        <li>
                                            <a href="#"><i class="icon-user"></i></a>
                                            <ul>
                                                {% if nurgulToken != "" %}
                                                <li><a href="#"
                                                        style="font-weight: bold;color: #cc1155;">{{user_name}}{{user_phone}}</a>
                                                </li>
                                                <!-- <li><a href="{{'Account'|page}}">{{'account.title'|_}}</a></li> -->
                                                <li><a href="{{'wishlist'|page}}">{{'whishlist.title'|_}}</a></li>
                                                <li><a href="javascript:;" data-request="onLogOutNurgul"
                                                        data-request-redirect="/"
                                                        style="font-weight: bold;">{{'logout.title'|_}}</a></li>
                                                {% else %}
                                                <li><a href="{{'login'|page}}">{{'login.title'|_}}</a></li>
                                                <li><a href="{{'register'|page}}">{{'register.title'|_}}</a></li>
                                                {% endif %}


                                            </ul>
                                        </li>
                                    </ul>
                                </div>
                            </li>
                            <li>
                                <!-- mini-cart 2 -->
                                <div class="mini-cart-icon mini-cart-icon-2">
                                    <a href="#ltn__utilize-cart-menu" class="ltn__utilize-toggle">
                                        <span class="mini-cart-icon">
                                            <i class="icon-handbag"></i>
                                            <sup id="cart_qty">0</sup>
                                        </span>
                                        <h6><span>{{'cart.title'|_}}</span> <span class="ltn__secondary-color"
                                                id="cart_total">0.00 TMT</span></h6>
                                    </a>
                                </div>
                            </li>
                            <li>
                                <!-- Mobile Menu Button -->
                                <div class="mobile-menu-toggle d-lg-none">
                                    <a href="#ltn__utilize-mobile-menu" class="ltn__utilize-toggle">
                                        <svg viewBox="0 0 800 600">
                                            <path
                                                d="M300,220 C300,220 520,220 540,220 C740,220 640,540 520,420 C440,340 300,200 300,200"
                                                id="top"></path>
                                            <path d="M300,320 L540,320" id="middle"></path>
                                            <path
                                                d="M300,210 C300,210 520,210 540,210 C740,210 640,530 520,410 C440,330 300,190 300,190"
                                                id="bottom"
                                                transform="translate(480, 320) scale(1, -1) translate(-480, -318) ">
                                            </path>
                                        </svg>
                                    </a>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- ltn__header-middle-area end -->

    <!-- header-bottom-area start -->
    <div
        class="header-bottom-area ltn__border-top ltn__header-sticky  ltn__sticky-bg-white ltn__primary-bg---- menu-color-white---- d-none d-lg-block">
        <div class="container">
            <div class="row">
                <div class="col header-menu-column justify-content-center">
                    <div class="sticky-logo">
                        <div class="site-logo">
                            <a href="/"><img src="{{'assets/logo_n.svg'|theme}}" alt="Nurgul" style="width: 70%;"></a>
                        </div>
                    </div>
                    <div class="header-menu header-menu-2">
                        <nav>
                            <div class="ltn__main-menu">
                                <ul>
                                    {% for item in staticMenu.menuItems %}

                                    {% if not item.viewBag.isHidden and item.items|length %}

                                    <li class="menu-icon"><a href="#"> {{ item.title }}</a>
                                        <ul>
                                            {% for item in item.items %}
                                            <li><a href="{{ item.url }}">{{ item.title }}</a></li>
                                            {% endfor %}
                                        </ul>
                                    </li>


                                    {% elseif not item.viewBag.isHidden %}

                                    <li><a href="{{ item.url }}">{{ item.title }}</a></li>


                                    {% endif %}
                                    {% endfor %}

                                    <li class="menu-icon">
                                        <a href="#" style="color: #cc1155;text-transform:uppercase;"> {% if activeLocale == 'tm' %} TÜRKMENÇE {% else %} Русский {% endif %} </a>
                                        <ul>
                                            {% if activeLocale == 'tm' %}
                                            <li><a href="javascript:;" data-request="onSwitchLocale" data-request-data="locale: 'ru'">Русский</a></li>
                                            {% else %}
                                            <li><a href="javascript:;" data-request="onSwitchLocale" data-request-data="locale: 'tm'">Türkmençe</a></li>
                                            {% endif %}

                                        </ul>
                                    </li>
                                </ul>
                            </div>
                        </nav>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- header-bottom-area end -->
</header>
<!-- HEADER AREA END -->

{% if nurgulToken != "" %}
{% put scripts %}
<script>
    $('#emptyC').show();

    oc.ajax('onGetCart', {
        success: function (data) {
            if (data.data != null) {
                $('#emptyC').hide();

                var cart = data.data;
                console.log(data);
                console.log(cart.vendors["nurgulShop"]);

                $('#cart_qty').html(cart.items_count);
                $('#cart_qty_mobile').html(cart.items_count);
                $('#cart_total').html(cart.formatted_grand_total);
                $('#cart_total_aside').html(cart.formatted_grand_total);

                $('#cart_page_total').html(cart.formatted_grand_total);

                for (var cart of cart.vendors["nurgulShop"]) {
                    // console.log(product.hasOwnProperty('special_price'));
                    $('#cart_inside').append(
                        `<div class="mini-cart-item clearfix">
                        <div class="mini-cart-img">
                            <a href="/product/detail/` + cart.additional.product_id + `"><img src="` + cart.product.images[0].small_image_url + `" alt="Image"></a>
                            <a href="javascript:;" class="mini-cart-item-delete" onClick="deleteItem(`+ cart.id + `);"><i class="icon-trash"></i></a>
                        </div>
                        <div class="mini-cart-info">
                            <h6><a href="/product/detail/` + cart.additional.product_id + `">` + cart.product.name + `</a></h6>
                            <span class="mini-cart-quantity">`+ cart.additional.quantity + ` x ` + cart.formatted_price + `</span>
                        </div>
                    </div>`);

                    $('#cart_page_inside').append(
                        `<tr>
                            <td class="cart-product-remove"><a href="javascript:;" data-request="onDeleteCartItemPage" data-request-data="item_id: `+ cart.id +`"><div>x</div></a></td>
                            <td class="cart-product-image">
                                <a href="/product/detail/` + cart.additional.product_id + `"><img src="` + cart.product.images[0].small_image_url + `" alt="#"></a>
                            </td>
                            <td class="cart-product-info">
                                <h4><a href="/product/detail/` + cart.additional.product_id + `">` + cart.product.name + `</a></h4>
                            </td>
                            <td class="cart-product-price">` + cart.formatted_price + `</td>
                            <td class="cart-product-quantity">
                                <div class="cart-plus-minus">
                                    <input type="text" value="`+ cart.additional.quantity + `" name="qtybutton"
                                        class="cart-plus-minus-box">
                                </div>
                            </td>
                            <td class="cart-product-subtotal">` + cart.formatted_total + `</td>
                        </tr>`);
                }

            }
        }
    })

    function deleteItem(itemId) {
        oc.ajax('onDeleteCartItem', {
            data: { item_id: itemId },
            success: function (data) {
                if (data.data != null) {
                    $('#cart_qty').html("");
                    $('#cart_total').html("");
                    $('#cart_total_aside').html("");
                    $('#cart_inside').html("");

                    var cart = data.data;
                    console.log(cart.vendors["nurgulShop"]);
                    $('#emptyC').hide();
                    $('#cart_qty').html(cart.items_count);
                    $('#cart_total').html(cart.formatted_grand_total);
                    $('#cart_total_aside').html(cart.formatted_grand_total);

                    for (var cart of cart.vendors["nurgulShop"]) {
                        // console.log(product.hasOwnProperty('special_price'));
                        $('#cart_inside').append(
                            `<div class="mini-cart-item clearfix">
                        <div class="mini-cart-img">
                            <a href="/product/detail/` + cart.additional.product_id + `"><img src="` + cart.product.images[0].small_image_url + `" alt="Image"></a>
                            <a href="javascript:;" class="mini-cart-item-delete" onClick="deleteItem(`+ cart.id + `);"><i class="icon-trash"></i></a>
                        </div>
                        <div class="mini-cart-info">
                            <h6><a href="/product/detail/` + cart.additional.product_id + `">` + cart.product.name + `</a></h6>
                            <span class="mini-cart-quantity">`+ cart.additional.quantity + ` x ` + cart.formatted_price + `</span>
                        </div>
                    </div>`);
                    }
                }else{
                    $('#cart_qty').html("0");
                    $('#cart_total').html("0.00 TMT");
                    $('#cart_total_aside').html("0.00 TMT");
                    // $('#cart_inside').html("");
                    $('#cart_inside').html(`<div id="emptyC" style='text-align:center'>{{'empty.cart'|_}}</div>`);
                }
                oc.flashMsg({
                    message: "{{'deleted.cart.success'|_}}",
                    type: 'success',
                    interval: 3
                });
            }
        })
    }
</script>
{% endput %}
{% endif %}
