{% set category = __SELF__.category %}
{% set users = __SELF__.users %}
{% set subs = __SELF__.subcategories %}
<!-- Breadcumb Area -->
<div class="breadcumb_area">
    <div class="container h-100">
        <div class="row h-100 align-items-center">
            <div class="col-12">
                <h5>Kategoriýa</h5>
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="{{ 'index'|page }}">Esasy sahypa</a></li>
                    {% if category.primary_key > 0 %}
                        <li class="breadcrumb-item"><a href="{{ 'category-profile'|page({categorySlug: category.parent.slug}) }}">{{ category.parent.name }}</a></li>
                    {% endif %}
                    <li class="breadcrumb-item active">{{ category.name }}</li>
                </ol>
            </div>
        </div>
    </div>
</div>
<!-- Breadcumb Area -->


<!-- Shop Catagory Area -->
<div class="shop_by_catagory_area section_padding_0">
    <div class="container">
   
        <div class="row">
            <div class="col-12">
                <div class="shop_by_catagory_slides owl-carousel">
                    <!-- Single Slide -->
                    <div class="single_catagory_slide">
                        <a href="{{ 'category-profile'|page({categorySlug: category.slug}) }}">
                            <img src="{{ 'assets/img/core-img/hemmesi2.png'|theme|resize(127, 127, { mode: 'crop' }) }}" alt="Gurluşyk, Gurluşyk platform, bezeg gurluşyk, gipsler merkezi, {{ subcategory.name }}">
                        </a>
                        <p>Hemmesi</p>
                    </div>
                    
                    {% for subcategory in category.subs %}
                            {% if subcategory.subs.count > 0 %}
                                <div class="single_catagory_slide">
                                    <a href="{{ 'category-profile'|page({categorySlug: subcategory.slug}) }}">
                                        <img src="{{ subcategory.icon|media|resize(127, 127, { mode: 'crop' }) }}" alt="Gurluşyk, Gurluşyk platform, bezeg gurluşyk, gipsler merkezi, {{ subcategory.name }}">
                                    </a>
                                    <p>{{ subcategory.name }}</p>
                                </div>
                            {% else %}
                                <div class="single_catagory_slide">
                                    <a href="{{ 'category-products'|page({categorySlug: subcategory.slug}) }}">
                                        <img src="{{ subcategory.icon|media|resize(127, 127, { mode: 'crop' }) }}" alt="Gurluşyk, Gurluşyk platform, bezeg gurluşyk, gipsler merkezi, {{ subcategory.name }}">
                                    </a>
                                    <p>{{ subcategory.name }}</p>
                                </div>
                            {% endif %}
                    {% endfor %}
                    
                </div>
            </div>
        </div>
    </div>
</div>
<!-- Shop Catagory Area -->

<!-- Brands Area -->
<section class="catagories_area home-3 section_padding_70_70">
    <div class="container">
        <div class="row justify-content-start">

            {% for user in users %}

                    <div class="col-6 col-md-4 col-lg-4 mt-4">
                        <a href="{{ 'user-profile'|page({id: user.id}) }}">
                            <div class="userBannerBg">
                                <div class="single_catagory">
                                    <img src="{{ user.banner|media|resize( 950, 535, {mode: 'crop'} )}}" alt="Gurluşyk, Gurluşyk Platforma, Bezeg, Gipsler merkezi, {{ user.shop_title }}, {{ user.name }}">
                                </div>
                                <div class="userBannerTitle">
                                    {{ user.shop_title }}
                                </div>
                            </div>
                        </a>
                    </div>

            {% endfor %}

        </div>
    </div>
</section>
<!-- Brands Area -->

{% if category.subs.count == 0 %}
<div class="container mb-5">
    <div class="row d-block justify-content-center align-items-center">
        <div class="col-6 d-block mx-auto">
           <div class="text-center">
              <img src="{{ 'assets/img/core-img/no-products.png'|theme }}" alt="Gurluşyk, Gurluşyk platform, bezeg gurluşyk, gipsler merkezi">
          </div>
        </div>
        <div class="col-6 d-block mx-auto">
           <div class="text-center">
              <p>Şu wagtlykça bu bölümde haryt ýok</p>
          </div>
        </div>
      </div>
</div>
{% else %}
    <div class="container">
        <div class="shop_grid_product_area">
            <div class="row justify-content-start">
        {% for subcategory in category.subs %}
            {% if subcategory.subs.count() > 0 %}
                {% for subsubcategory in subcategory.subs %}
                    {% for product in subsubcategory.products %}
                     <!-- Single Product -->
                        <div class="col-6 col-xs-6 col-sm-6 col-md-4 col-lg-4">
                            <div class="single-product-area mb-30">
                                <a href="{{ 'product'|page({id: product.id}) }}">
                                    <div class="product_image">
                                        <!-- Product Image -->
                                        <img class="normal_img" src="{{ product.images[0].thumb(680,700,{'mode':'crop'}) }}" alt="Gurluşyk, Gurluşyk platform, bezeg gurluşyk, gipsler merkezi, {{ product.name }}">
                                        {% if product.images_count > 1 %}
                                            <img class="hover_img" src="{{ product.images[1].thumb(680,700,{'mode':'crop'}) }}" alt="Gurluşyk, Gurluşyk platform, bezeg gurluşyk, gipsler merkezi, {{ product.name }}">
                                        {% endif %}
                                        <!-- Wishlist -->
                                        <div class="product_wishlist">
                                            {% if user %}
                                                <a 
                                                data-request="onCreateFav" 
                                                data-request-flash
                                                data-request-validate
                                                data-request-data="product_id: {{ product.id }}" 
                                                href="#"><i class="icofont-heart"></i></a>
                                            {% else %}
                                                <a href="{{ 'login'|page }}"><i class="icofont-heart"></i></a>
                                            {% endif %}
                                        </div>
                                    </div>
                                </a>
            
                                <!-- Product Description -->
                                <div class="product_description">
                                    <!-- Add to cart -->
                                    {% if user %}
                                        <div class="product_add_to_cart addToCard" data-id="{{ product.id }}" data-price="{{ product.price }}" data-image="{{ product.images[0].path }}" data-name="{{ product.name }}"  data-vendor="{{ product.vendor.id }}">
                                            <input type="hidden" min="1" id="quantity{{ product.id }}" value="1">
                                            <a href="#"><i class="icofont-shopping-cart"></i> Sebede goş</a>
                                        </div>
                                    {% else %}
                                        <div class="product_add_to_cart">
                                            <a href="{{ 'login'|page }}"><i class="icofont-shopping-cart"></i> Sebede goş</a>
                                        </div>
                                    {% endif %}
                                    <!-- Quick View -->
                                    <div class="product_quick_view">
                                        <a href="#" data-toggle="modal" data-target="#quickview{{product.id}}"><i class="icofont-eye-alt"></i> Doly maglumat</a>
                                    </div>
                                     <p class="brand_name">{{product.vendor.shop_title}}</p>
                                    <a href="{{ 'product'|page({id: product.id}) }}">{{ product.name }}</a>
                                    <h6 class="product-price">{{ product.price }} TMT</h6>
                                </div>
                            </div>
                        </div>
                    {% endfor %}
                {% endfor %}
            {% else %}
            
                
                {% for product in subcategory.products %}
                     <!-- Single Product -->
                        <div class="col-6 col-xs-6 col-sm-6 col-md-4 col-lg-4">
                            <div class="single-product-area mb-30">
                                <a href="{{ 'product'|page({id: product.id}) }}">
                                    <div class="product_image">
                                        <!-- Product Image -->
                                        <img class="normal_img" src="{{ product.images[0].thumb(680,700,{'mode':'crop'}) }}" alt="Gurluşyk, Gurluşyk platform, bezeg gurluşyk, gipsler merkezi, {{ product.name }}">
                                        {% if product.images_count > 1 %}
                                            <img class="hover_img" src="{{ product.images[1].thumb(680,700,{'mode':'crop'}) }}" alt="Gurluşyk, Gurluşyk platform, bezeg gurluşyk, gipsler merkezi, {{ product.name }}">
                                        {% endif %}
                                        <!-- Wishlist -->
                                        <div class="product_wishlist">
                                            {% if user %}
                                                <a 
                                                    data-request="onCreateFav" 
                                                    data-request-flash
                                                    data-request-validate
                                                    data-request-data="product_id: {{ product.id }}" 
                                                    href="#"><i class="icofont-heart"></i></a>
                                            {% else %}
                                                <a href="{{ 'login'|page }}"><i class="icofont-heart"></i></a>
                                            {% endif %}
                                        </div>
                                    </div>
                                </a>
            
                                <!-- Product Description -->
                                <div class="product_description">
                                    <!-- Add to cart -->
                                    {% if user %}
                                        <div class="product_add_to_cart addToCard" data-id="{{ product.id }}" data-price="{{ product.price }}" data-image="{{ product.images[0].path }}" data-name="{{ product.name }}"  data-vendor="{{ product.vendor.id }}">
                                            <input type="hidden" min="1" id="quantity{{ product.id }}" value="1">
                                            <a href="#"><i class="icofont-shopping-cart"></i> Sebede goş</a>
                                        </div>
                                    {% else %}
                                        <div class="product_add_to_cart">
                                            <a href="{{ 'login'|page }}"><i class="icofont-shopping-cart"></i> Sebede goş</a>
                                        </div>
                                    {% endif %}
                                    <!-- Quick View -->
                                    <div class="product_quick_view">
                                        <a href="#" data-toggle="modal" data-target="#quickview{{product.id}}"><i class="icofont-eye-alt"></i> Doly maglumat</a>
                                    </div>
                                     <p class="brand_name">{{product.vendor.shop_title}}</p>
                                    <a href="{{ 'product'|page({id: product.id}) }}">{{ product.name }}</a>
                                    <h6 class="product-price">{{ product.price }} TMT</h6>
                                </div>
                            </div>
                        </div>
                    {% endfor %}
            {% endif %}
        {% endfor %}
            </div>
        </div>
    </div>
    
    
    <!-- product modals -->
    {% for subcategory in category.subs %}
        {% if subcategory.subs.count() > 0 %}
            {% for subsubcategory in subcategory.subs %}
                {% for product in subsubcategory.products %}
            <!-- Quick View Modal Area -->
            <div class="modal fade" id="quickview{{product.id}}" tabindex="-1" role="dialog" aria-labelledby="quickview" aria-hidden="true">
                <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
                    <div class="modal-content">
                        <button type="button" class="close btn" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                        <div class="modal-body">
                            <div class="quickview_body">
                                <div class="container">
                                    <div class="row">
                                        <div class="col-12 col-lg-5">
                                            <div class="quickview_pro_img">
                                                <img class="first_img" src="{{ product.images[0].thumb(500,625,{'mode':'crop'}) }}" alt="Gurluşyk, Gurluşyk platform, bezeg gurluşyk, gipsler merkezi, {{ product.name }}">
                                                {% if product.images_count > 1 %}
                                                    <img class="hover_img" src="{{ product.images[1].thumb(500,625,{'mode':'crop'}) }}" alt="Gurluşyk, Gurluşyk platform, bezeg gurluşyk, gipsler merkezi, {{ product.name }}">
                                                {% endif %}
                                            </div>
                                        </div>
                                        <div class="col-12 col-lg-7">
                                            <div class="quickview_pro_des">
                                                <h4 class="title">{{ product.name }}</h4>
                                                <div class="top_seller_product_rating mb-15">
                                                    <i class="fa fa-star" aria-hidden="true"></i>
                                                    <i class="fa fa-star" aria-hidden="true"></i>
                                                    <i class="fa fa-star" aria-hidden="true"></i>
                                                    <i class="fa fa-star" aria-hidden="true"></i>
                                                    <i class="fa fa-star" aria-hidden="true"></i>
                                                </div>
                                                <h5 class="price">{{ product.price }} TMT</h5>
                                                <p>{{ html_limit(product.description, 100) }}</p>
                                                <a href="{{ 'product'|page({id: product.id}) }}">Giňişleýin maglumat</a>
                                            </div>
                                            <!-- Add to Cart Form -->
                                            <form class="cart" method="post">
                                                <div class="quantity">
                                                    <input type="number" class="qty-text form-control" id="quantity{{ product.id }}" step="1" min="1" value="1">
                                                </div>
                                                {% if user %}
                                                 <div class="product_add_to_cart addToCard" data-id="{{ product.id }}" data-price="{{ product.price }}" data-image="{{ product.images[0].path }}" data-name="{{ product.name }}"  data-vendor="{{ product.vendor.id }}">  
                                                        <a href="#" class="btn btn-primary mt-1 mt-md-0 ml-1 ml-md-3">Sebede goş</a>
                                                 </div>
                                                {% else %}
                                                    <div class="product_add_to_cart" data-id="{{ product.id }}" data-price="{{ product.price }}" data-image="{{ product.images[0].path }}" data-name="{{ product.name }}"  data-vendor="{{ product.vendor.id }}">  
                                                            <a href="{{ 'login'|page }}" class="btn btn-primary mt-1 mt-md-0 ml-1 ml-md-3">Sebede goş</a>
                                                     </div>
                                                {% endif %}
                                                <!-- Wishlist -->
                                                <div class="modal_pro_wishlist">
                                                    {% if user %}
                                                        <a 
                                                            data-request="onCreateFav" 
                                                            data-request-flash
                                                            data-request-validate
                                                            data-request-data="product_id: {{ product.id }}" 
                                                            href="#"><i class="icofont-heart"></i></a>
                                                    {% else %}
                                                        <a href="{{ 'login'|page }}"><i class="icofont-heart"></i></a>
                                                    {% endif %}
                                                </div>
            
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- Quick View Modal Area -->
                {% endfor %}
            {% endfor %}
        {% else %}
            {% for product in subcategory.products %}
            <div class="modal fade" id="quickview{{product.id}}" tabindex="-1" role="dialog" aria-labelledby="quickview" aria-hidden="true">
                <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
                    <div class="modal-content">
                        <button type="button" class="close btn" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                        <div class="modal-body">
                            <div class="quickview_body">
                                <div class="container">
                                    <div class="row">
                                        <div class="col-12 col-lg-5">
                                            <div class="quickview_pro_img">
                                                <img class="first_img" src="{{ product.images[0].thumb(500,625,{'mode':'crop'}) }}" alt="Gurluşyk, Gurluşyk platform, bezeg gurluşyk, gipsler merkezi, {{ product.name }}">
                                                {% if product.images_count > 1 %}
                                                    <img class="hover_img" src="{{ product.images[1].thumb(500,625,{'mode':'crop'}) }}" alt="Gurluşyk, Gurluşyk platform, bezeg gurluşyk, gipsler merkezi, {{ product.name }}">
                                                {% endif %}
                                            </div>
                                        </div>
                                        <div class="col-12 col-lg-7">
                                            <div class="quickview_pro_des">
                                                <h4 class="title">{{ product.name }}</h4>
                                                <div class="top_seller_product_rating mb-15">
                                                    <i class="fa fa-star" aria-hidden="true"></i>
                                                    <i class="fa fa-star" aria-hidden="true"></i>
                                                    <i class="fa fa-star" aria-hidden="true"></i>
                                                    <i class="fa fa-star" aria-hidden="true"></i>
                                                    <i class="fa fa-star" aria-hidden="true"></i>
                                                </div>
                                                <h5 class="price">{{ product.price }} TMT</h5>
                                                <p>{{ html_limit(product.description, 100) }}</p>
                                                <a href="{{ 'product'|page({id: product.id}) }}">Giňişleýin maglumat</a>
                                            </div>
                                            <!-- Add to Cart Form -->
                                            <form class="cart" method="post">
                                                <div class="quantity">
                                                    <input type="number" class="qty-text form-control" id="quantity{{ product.id }}" step="1" min="1" value="1">
                                                </div>
                                                {% if user %}
                                                 <div class="product_add_to_cart addToCard" data-id="{{ product.id }}" data-price="{{ product.price }}" data-image="{{ product.images[0].path }}" data-name="{{ product.name }}"  data-vendor="{{ product.vendor.id }}">  
                                                        <a href="#" class="btn btn-primary mt-1 mt-md-0 ml-1 ml-md-3">Sebede goş</a>
                                                 </div>
                                                {% else %}
                                                    <div class="product_add_to_cart" data-id="{{ product.id }}" data-price="{{ product.price }}" data-image="{{ product.images[0].path }}" data-name="{{ product.name }}"  data-vendor="{{ product.vendor.id }}">  
                                                            <a href="{{ 'login'|page }}" class="btn btn-primary mt-1 mt-md-0 ml-1 ml-md-3">Sebede goş</a>
                                                     </div>
                                                {% endif %}
                                                <!-- Wishlist -->
                                                <div class="modal_pro_wishlist">
                                                    {% if user %}
                                                        <a 
                                                            data-request="onCreateFav" 
                                                            data-request-flash
                                                            data-request-validate
                                                            data-request-data="product_id: {{ product.id }}" 
                                                            href="#"><i class="icofont-heart"></i></a>
                                                    {% else %}
                                                        <a href="{{ 'login'|page }}"><i class="icofont-heart"></i></a>
                                                    {% endif %}
                                                </div>
            
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            {% endfor %}
        {% endif %}
    {% endfor %}
{% endif %}
