lazy_load_group.push( { id: 'js-bottom-product-box', target: '#js-bottom-product-box', loadFn: function () { getRelativeProduct(); }, }, { id: 'js-review-holder', target: '#js-review-holder', loadFn: function () { getRatingComment(); }, }, ) // GET PRODUCT RELATIVE function getRelativeProduct() { var categoryID = parseInt($('.section-details').attr('data-item_category-id')); var params = { action_type: "product-list", category: categoryID, }; var target = "#js-bottom-product-box"; Hura.Ajax.get("product", params).then(function (data) { //console.log(data.list) var currentProductID = parseInt($('.section-details').attr('data-item_id')); var newDataList = data.list.filter(item => item.id !== currentProductID); if (data.list.length > 0) { var html = Hura.Template.parse(listRelativeProduct, newDataList); Hura.Template.render(target, html); } else { $("#js-bottom-product-box").html(`
Sản phẩm đang cập nhập
`) } }); } // SWIPER BOTTOM PRODUCT BOX function productBottomBoxSwiper() { new Swiper(".bottom-product-box-swiper", { slidesPerView: 4, spaceBetween: 12, rewind: true, navigation: { nextEl: ".swiper-button-next", prevEl: ".swiper-button-prev", }, breakpoints: { // when window width is >= 1600px 1600: { slidesPerView: 5, }, }, }); } const galleryTop = new Swiper(".gallery-top", { spaceBetween: 16, slidesPerView: 1, thumbs: { swiper: galleryThumbs, }, // AUTO SILDED AT FISRT AND END on: { slideChange: function () { let activeIndex = this.activeIndex + 1; let activeSlide = document.querySelector( `.gallery-thumbs .swiper-slide:nth-child(${activeIndex})` ); let nextSlide = document.querySelector( `.gallery-thumbs .swiper-slide:nth-child(${activeIndex + 1})` ); let prevSlide = document.querySelector( `.gallery-thumbs .swiper-slide:nth-child(${activeIndex - 1})` ); if ( nextSlide && !nextSlide.classList.contains("swiper-slide-visible") ) { this.thumbs.swiper.slideNext(); } else if ( prevSlide && !prevSlide.classList.contains("swiper-slide-visible") ) { this.thumbs.swiper.slidePrev(); } }, }, }); // FANCY-BOX function fancyBox() { Fancybox.bind('[data-fancybox="gallery"]', { Toolbar: { display: [ { id: "counter", position: "center", }, "zoom", "slideshow", "fullscreen", "thumbs", "close", ], }, //click: "unset", on: { initLayout: (fancybox) => { // Create left column const $leftCol = document.createElement("div"); $leftCol.classList.add("fancybox__leftCol"); while (fancybox.$container.firstChild) { $leftCol.appendChild(fancybox.$container.firstChild); } // Add elements to DOM fancybox.$container.appendChild(fancybox.$backdrop); fancybox.$container.appendChild($leftCol); fancybox.$leftCol = $leftCol; }, "Carousel.ready Carousel.change": (fancybox, carousel, slideIndex) => { // Get index of the current gallery item slideIndex = slideIndex === undefined ? carousel.options.initialPage : slideIndex; // console.log(slideIndex); // Get link related to current item const $trigger = fancybox.items[slideIndex].$trigger; // Get data from `data-info` attribute const data = $trigger.dataset.info || ""; }, }, }); } fancyBox(); // ADD PRODUCT TO CART - PRODUCT DETAILS function addProductToCart(product_id, variant_id_fake, props) { const props_quantity = parseInt($(".js-buy-quantity-temp").attr("value")); const stockQuantity = parseInt($(".bk-check-out-of-stock").attr("value")); //console.log(stockQuantity); var variant_id = 0; var data = $('.js-variant-option-container input[type="hidden"]').val(); if (data) { var newData = JSON.parse(data) variant_id = newData.variant_id; } if (stockQuantity) { var product_props = { quantity: props_quantity, buyer_note: "", }; Hura.Cart.Product.add(product_id, variant_id, product_props).then(function ( response ) { // Error response if (response.status === "error") { if (response.error_type == "item-in-cart") { alert("Sản phẩm đã trong giỏ hàng"); } else if (response.error_type == "invalid-item-id") alert("ID sản phẩm không đúng"); else alert(response.message); } // Success response else { modalSuccess(); change_cart_amount(); } }); } else { alert("Sản phẩm không có sẵn. Vui lòng chọn sản phẩm khác hoặc liên hệ. Xin cảm ơn!") } } // BUY NOW function buyNow(product_id, variant_id_fake, props) { addProductToCart(product_id, variant_id_fake, props); const stockQuantityCheck = parseInt($(".bk-check-out-of-stock").attr("value")); if (stockQuantityCheck) { setTimeout(function () { window.location.href = "./cart"; }, 1500); } } // LANG NGHE THAY DOI SO LUONG SP function listenQuantityBuy() { const $track_change = $(".js-quantity-change"); //thay doi so luong sp mua, neu nhap so luong $track_change.on("change", function (e) { if($(this).val() < 1 && 1<2) $(this).val(1); $(".js-buy-quantity-temp").attr("value", e.target.value); }); //thay doi so luong sp theo - hoac + $track_change.on("click", function (e) { if (e.target.nodeName === "INPUT") return; let quantity_change = parseInt(this.getAttribute("data-value")); let $row = $(this).closest(".cart-quantity-select"); let current_quantity = parseInt($row.find(".js-buy-quantity").val()); //loai bo so luong vo ly if(current_quantity + quantity_change < 1 && 1 < 2) { $(".js-buy-quantity").val(1); return ; } let totalQuantity = current_quantity + quantity_change; $row.find(".js-buy-quantity").val(totalQuantity); $(".js-buy-quantity-temp").attr("value", totalQuantity); }); } function renReplyReview(new_replies){ var html = ''; new_replies.forEach(function(value,item){ var check_user = ` `+value.user_name+` `+value.user_name+``; if (value.is_user_admin == 1) { check_user = ` `+value.user_name+` QTV` } if(value.is_user_admin == 1 || value.approved == 1){ html += `Bạn đang đăng nhập là Admin
Gửi bình luậnBạn đang đăng nhập là Admin
`; } else if ( is_admin_login == 'no' && customer_info.length > 0 ) { formReply = ` `; } else formReply = `