$(".sp-slider-small").slick({
slidesToShow: 5,
slidesToScroll: 1,
arrows: false,
infinite: false,
responsive: [
{
breakpoint: 1120,
settings: {
slidesToShow: 4,
},
},
{
breakpoint: 1000,
settings: {
slidesToShow: 3,
},
},
{
breakpoint: 800,
settings: {
slidesToShow: 2,
},
},
{
breakpoint: 768,
settings: {
slidesToShow: 5,
},
},
{
breakpoint: 600,
settings: {
slidesToShow: 3,
},
},
{
breakpoint: 400,
settings: {
slidesToShow: 2,
},
},
],
});
$(".date").datetimepicker({
pickTime: false,
});
$(".datetime").datetimepicker({
pickDate: true,
pickTime: true,
});
$(".time").datetimepicker({
pickDate: false,
});
$("button[id^='button-upload']").on("click", function () {
var node = this;
$("#form-upload").remove();
$("body").prepend(
'
'
);
$("#form-upload input[name='file']").trigger("click");
if (typeof timer != "undefined") {
clearInterval(timer);
}
timer = setInterval(function () {
if ($("#form-upload input[name='file']").val() != "") {
clearInterval(timer);
$.ajax({
url: "index.php?route=tool/upload",
type: "post",
dataType: "json",
data: new FormData($("#form-upload")[0]),
cache: false,
contentType: false,
processData: false,
beforeSend: function () {
$(node).button("loading");
},
complete: function () {
$(node).button("reset");
},
success: function (json) {
$(".text-danger").remove();
if (json["error"]) {
$(node)
.parent()
.find("input")
.after('' + json["error"] + "
");
}
if (json["success"]) {
alert(json["success"]);
$(node).parent().find("input").attr("value", json["code"]);
}
},
error: function (xhr, ajaxOptions, thrownError) {
alert(
thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText
);
},
});
}
}, 500);
});
$("#promotion-request").on("click", function () {
$("#promotion_error").html("");
$("#model").modal();
});
function submitPromotion() {
$.ajax({
url:
"index.php?route=product/product/promotion&product_id=" + product_id,
type: "post",
data: $("#model textarea"),
dataType: "json",
complete: function () {
$("#model").modal();
},
success: function (json) {
if (json["error"]) {
$("#btn-submit-promotion").hide();
$("#model .modal-title").html("");
$("#model .modal-body").html(json["error"]);
}
if (json["success"]) {
$("#model .modal-body").html(json["success"]);
}
},
});
}
$(document).ready(function () {
$(".qtyBtn").click(function () {
if ($(this).hasClass("plus")) {
var i = $(".qty #input-quantity").val();
i++, $(".qty #input-quantity").val(i);
} else {
var i = $(".qty #input-quantity").val();
i--, i > 0 && $(".qty #input-quantity").val(i);
}
});
});
if ($(".more-view-description").height() >= 600) {
$(".more-view-description-btn").show();
}
$("#view-more").click(function () {
const { scrollY } = window;
setTimeout(() => {
window.scrollTo(0, scrollY);
});
$(".more-view-description").css("max-height", "100%");
$("#view-more").hide();
$("#hidden-view").show();
$(".more-view-description").removeClass("limit-height");
});
$("#hidden-view").click(function () {
$(".more-view-description").css("max-height", "600px");
$("#hidden-view").hide();
$("#view-more").show();
$(".more-view-description").addClass("limit-height");
});
$(".btn_rate").on("click", function () {
$(this).hide();
$(".btn_close_rate").show();
$("#comment").show();
});
$(".btn_close_rate").on("click", function () {
$(this).hide();
$(".btn_rate").show();
$("#comment").hide();
});
$("#click_fullscreen").on("click", function () {
$(".gallery_slide_show").show();
});
function click_show_slide() {
$("#slide_dedail").show();
$("header").hide();
$(".top-header").hide();
$("body").css("overflow", "hidden");
var $gallery = $("#gallery"),
delay = 5000;
$.ajax("https://flickr.com/services/rest/", {
data: {
format: "json",
method: "flickr.interestingness.getList",
api_key: "270e736b0e42643aab5aab7819164d84",
},
dataType: "jsonp",
jsonp: "jsoncallback",
}).done(function (data) {
var $image, $link, base_url, t_url, i_url;
$gallery.gallerie().gallerie("open");
});
}
$(document).ready(function () {
$("[contenteditable]").focusout(function () {
var element = $(this);
if (!element.text().trim().length) {
element.empty();
}
});
listComment();
});
function listComment() {
let review_id = $('#sort_review_id').val();
$.ajax({
method: "get",
url: "index.php?route=product/product/get_list_comment",
data: {
limit: 5,
page: 1,
product_id: product_id,
review_id: review_id,
},
success: function (data) {
$("#list_comment").append(data);
},
});
}
function loadComment(t, e, o) {
let review_id = $('#sort_review_id').val();
$.ajax({
method: "get",
url: "index.php?route=product/product/loadComment",
data: {
limit: 5,
page: t,
product_id: product_id,
review_id: review_id,
},
success: function (data) {
$("#list_comment").append(data);
},
});
}
$(".loadMoreComment").on("click", function () {
$("#load-" + number_review).hide();
});
$(".no-login").on("click", function () {
$("#modal-offer-login").modal("hide");
});
$("#redirect-login").on("click", function () {
window.location.href = link_login;
});
$("#btn-affiliate").click(function () {
$(this).siblings("#link-affiliate").select();
document.execCommand("copy");
$("#btn-affiliate")
.attr("data-original-title", "ÄĂ£ copy thĂ nh cĂ´ng!")
.tooltip("show");
setTimeout(function () {
$("#btn-affiliate")
.attr("data-original-title", "Click để copy")
.tooltip("show");
}, 1500);
});
onloadfbq = function () {
window.fbq && window.fbq("track", "ViewContent", {
content_type: "product",
content_ids: product_id,
});
};
$("#btn-send-in-stock").on("click", function () {
$("#modal_in_stock").modal();
});
function submitInStock() {
$.ajax({
url:
"index.php?route=product/product/NotificationInStock&product_id=" + product_id,
type: "post",
data: $("#modal_in_stock textarea"),
dataType: "json",
complete: function () {
$("#modal_in_stock").modal();
},
success: function (json) {
if (json["error"]) {
$("#btn-submit-in-stock").hide();
$("#modal_in_stock .modal-title").html("");
$("#modal_in_stock .modal-body").html(json["error"]);
}
if (json["success"]) {
$(".modal-body").html(json["success"]);
}
},
});
}
// Add multi product steam wallet
$('#add-card-steam-wallet').click(function() {
$.ajax({
url: 'index.php?route=checkout/cart/addMultiple',
type: 'POST',
data: $('#form-steam-product').serialize(),
dataType: 'json',
beforeSend: function() {
$('#cart > button').button('loading');
$('#add-card-steam-wallet').button('loading');
},
complete: function() {
$('#cart > button').button('reset');
$('#add-card-steam-wallet').button('reset');
},
success: function(json) {
$('.alert, .text-danger').remove();
if (json['success']) {
$('#content').parent().before(' ' + json['success'] + '
');
// Need to set timeout otherwise it wont update the total
setTimeout(function() {
$('#cart > button').html(' ' + json['total'] + ' ');
$('#home-cart .heading span').html(json["total"].split(" ")[0]);
$('.quantity_mobile').html(json["total"].split(" ")[0]);
}, 100);
$('.alert-add-cart').css('display', 'unset');
clearTimeout(time_out_cart);
time_out_cart = setTimeout(function() {
$('.alert-add-cart').css('display', 'none')
}, 5000);
$('#cart > ul').load('index.php?route=common/cart/info ul li');
$('#home-cart > ul').load('index.php?route=common/cart/info ul li');
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
// Add multi product steam wallet and checkout cart
$('#checkout-steam-wallet').click(function() {
$.ajax({
url: 'index.php?route=checkout/cart/addMultiple',
type: 'POST',
data: $('#form-steam-product').serialize(),
dataType: 'json',
beforeSend: function() {
$('#cart > button').button('loading');
$('#checkout-steam-wallet').button('loading');
},
complete: function() {
$('#cart > button').button('reset');
$('#checkout-steam-wallet').button('reset');
},
success: function(json) {
$('.alert, .text-danger').remove();
if (json['success']) {
$('#content').parent().before(' ' + json['success'] + '
');
// Need to set timeout otherwise it wont update the total
setTimeout(function() {
$('#cart > button').html(' ' + json['total'] + ' ');
$('#home-cart .heading span').html(json["total"].split(" ")[0]);
$('.quantity_mobile').html(json["total"].split(" ")[0]);
}, 100);
$('.alert-add-cart').css('display', 'unset');
clearTimeout(time_out_cart);
time_out_cart = setTimeout(function() {
$('.alert-add-cart').css('display', 'none')
}, 5000);
$('#cart > ul').load('index.php?route=common/cart/info ul li');
$('#home-cart > ul').load('index.php?route=common/cart/info ul li');
location = 'index.php?route=checkout/checkout';
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
function check_email_vnpay_instant(json) {
if (json.customer_email) {
submit_vnpay_instant();
} else {
$('#vnpay-instant-modal').modal({
backdrop: 'static',
keyboard: true,
show: true
});
}
}
// remarketing
dataLayer =[]
dataLayer.push({
'ecomm_prodid' : product_id, // MĂ£ sản phẩm
'ecomm_pagetype' : first_category_id, // ID danh mục sản phẩm, lấy theo danh mục đầu tiĂªn
'ecomm_totalvalue': curent_price // GiĂ¡ hiện tại cá»§a sản phẩm.
});