{% put scripts %}

<script>
    function productCard(product) {

        var product_str = JSON.stringify(product);

        var card = `<div class="col-lg-3 col-md-4 col-sm-6 col-6">
                <div class="ltn__product-item text-center">
                    <div class="product-img">` +

            (product.images.length > 0 ?
                `<a href="/product/detail/` + product.id + `">
                            <img src="`+ product.images[0].original_image_url + `" alt="Nurgul ` + product.name + `" style="width: 400px;height: 280px;object-fit: fill;">
                        </a>
                        `
                :
                `<a href="/product/detail/` + product.id + `">
                            <img src="{{'assets/no_img.jpg'|theme}}" alt="Nurgul `+ product.name + `" style="width: 400px;height: 280px;object-fit: fill;">
                        </a>
                        `
            )

            +

            (product.hasOwnProperty('special_price') ?
                `<div class="product-badge">
                            <ul>
                                <li class="badge-2">{{'product.badge.discount'|_}}</li>
                            </ul>
                        </div>`
                :
                ``
            )

            +
            `<div class="product-hover-action product-hover-action-2">
                            <ul>
                                <li>`+
            "<a href='#' onClick='setModal(" + product_str + ")' title='Quick View' data-bs-toggle='modal' data-bs-target='#quick_view_modal'>"
            + `<i class="icon-magnifier"></i>
                                    </a>
                                </li>
                                <li class="add-to-cart">
                                    <a ` + ("{{nurgulToken}}" == "" ? `href='/login'` : `href="javascrip:;" data-request="onAddCart" data-request-data="product_id: `+ product.id +`, quantity: 1"`) + ` title="Add to Cart" >
                                        <span class="cart-text d-none d-xl-block">{{add}}</span>
                                        <span class="d-block d-xl-none"><i class="icon-handbag"></i></span>
                                    </a>
                                </li>
                                <li>
                                    <a` + ("{{nurgulToken}}" == "" ? ` href='/login'` : ` href="javascript:;" data-request="onSaveWishlist" data-request-data="product_id: `+ product.id +`" `) + ` title="Quick View">
                                        <i class="icon-heart"></i>
                                    </a>
                                </li>
                            </ul>
                        </div>
                    </div>
                    <div class="product-info">
                        <h2 class="product-title"><a href="product-details.html">`+ product.name + `</a></h2>
                        <div class="product-price">
                            <span>`+ product.formatted_price + `</span>`
            + (product.hasOwnProperty('special_price') ? `<del>` + product.formatted_regular_price + `</del>` : ``) +
            `</div>
                    </div>
                </div>
            </div>`;

        return card;
    }




    function productList(product) {

        var product_str = JSON.stringify(product);

        var list = `
        <div class="col-lg-12">
            <div class="ltn__product-item">
                <div class="product-img">
                    `

            +

            (product.images.length > 0 ?
                `
                        <a href="/product/detail/` + product.id + `">
                            <img style="height: 300px;width: 320px;object-fit: cover;" src="`+ product.images[0].original_image_url + `" alt="Nurgul ` + product.name + `" >
                        </a>
                        `
                :
                `
                        <a style="height: 300px;width: 320px;object-fit: cover;" href="/product/detail/` + product.id + `">
                            <img src="{{'assets/no_img.jpg'|theme}}" alt="Nurgul ` + product.name + `" >
                        </a>
                        `
            )

            +



            (product.hasOwnProperty('special_price') ?
                `<div class="product-badge">
                            <ul>
                                <li class="badge-1">{{'product.badge.discount'|_}}</li>
                            </ul>
                        </div>
                        `
                :

                ``
            )

            +
            `</div>
                <div class="product-info">
                    <h2 class="product-title"><a href=""/product/detail/` + product.id + `">` + product.name + `</a></h2>

                    <div class="product-price">
                        <span>`+ product.formatted_price + `</span>`
            + (product.hasOwnProperty('special_price') ? `<del>` + product.formatted_regular_price + `</del>` : ``) +
            `</div>

                <div class="product-brief">
                    <p>` + product.short_description+ `</p>
                </div>
                <div class="product-hover-action product-hover-action-2">
                    <ul>
                        <li>
                            `
            +

            "<a href='#' onClick='setModal(" + product_str + ")' title='Quick View' data-bs-toggle='modal' data-bs-target='#quick_view_modal'><i class='icon-magnifier'></i></a>"
            +
            `
                            </li>
                            <li class="add-to-cart">
                                <a ` + ("{{nurgulToken}}" == "" ? `href='/login'` : `href="javascrip:;" data-request="onAddCart" data-request-data="product_id: `+ product.id +`, quantity: 1"`) + ` title="Add to Cart">
                                    <span class="cart-text d-none d-xl-block">{{add}}</span>
                                    <span class="d-block d-xl-none"><i class="icon-handbag"></i></span>
                                </a>
                            </li>
                            <li>`+

                                `<a ` + ("{{nurgulToken}}" == "" ? ` href='/login'` : ` href="javascript:;" data-request="onSaveWishlist" data-request-data="product_id: `+ product.id +`" `) + ` title='Quick View'><i class='icon-heart'></i></a>` +
                            `</li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        `;

        return list;
    }
</script>

{% endput %}

