|
Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /var/www/rabbithabit.com/public_html/themes/3/js/ |
Upload File : |
function dynamicStockCondition(dynamicStockCondition) {
if (dynamicStockCondition == "Indent") {
//submit #submitToCart2 Indent
jQuery("#submitToCart2").off("click");
// jQuery("#submitToCart2").on("click", function () {
// var qty2 = jQuery("#qty2").val();
// alert("tes 2 : "+qty2);
// jQuery("#modalIndentTOC").modal("show");
// jQuery("#indentTOCAgree").off("click");
// jQuery("#indentTOCAgree").on("click", function () {
// jQuery("#modalIndentTOC").modal("hide");
// addToCart(chosenVarianDetailArray, qty2, baseUrl, productId, csrfHash);
// });
// });
jQuery("#submitToCart2").on("click", function () {
var qty2 = jQuery("#qty2").val();
// alert("tes 4 : "+qty2);
addToCart(chosenVarianDetailArray, qty2, baseUrl, productId, csrfHash);
});
} else if (dynamicStockCondition == "In Stock") {
//submit #submitToCart2 In Stock
jQuery("#submitToCart2").off("click");
jQuery("#submitToCart2").on("click", function () {
var qty2 = jQuery("#qty2").val();
// alert("tes 4 : "+qty2);
addToCart(chosenVarianDetailArray, qty2, baseUrl, productId, csrfHash);
});
} else {
jQuery("#submitToCart2").attr("disabled", true).css({
cursor: "not-allowed",
opacity: "0.7",
});
}
}
function initialProductDetail(
chosenVarianDetailArray,
productId,
baseUrl,
csrfHash,
indentTime,
indentDp,
callback = function (datax) {}
) {
var ses_eve_product = sessionStorage.getItem("ses_eve_product");
var ses_eve_product_id_pc = null;
if (ses_eve_product != undefined && ses_eve_product == "true") {
ses_eve_product_id_pc = sessionStorage.getItem("ses_eve_product_id_pc");
var part_id_pc = ses_eve_product_id_pc.split(";");
$("a.li_a_cvarian").each(function (idx, key) {
var t = $(this);
var attribute_id = t.data("attribute_id");
var attribute_detail_id = t.attr("data");
$.each(part_id_pc, function (idx2, key2) {
var part_id_pc_2 = part_id_pc[idx2].split("->");
var ses_attribute_id = part_id_pc_2[0];
var ses_attribute_detail_id = part_id_pc_2[1];
if (
attribute_id == ses_attribute_id &&
attribute_detail_id == ses_attribute_detail_id
) {
// alert(`${ses_attribute_id} and ${ses_attribute_detail_id}`);
t.click();
}
});
});
// sessionStorage.removeItem('ses_eve_product');
} else {
jQuery.ajax({
url: baseUrl + "ajax/initialproductdetail",
type: "POST",
data: {
product_id: productId,
attribute_detail_ids: chosenVarianDetailArray,
csrftestname: csrfHash,
},
success: function (data) {
if (data) {
/*---success----*/
var result = JSON.parse(data);
jQuery("#productImageContainer").html(result.image_content);
jQuery("#stockStatus").html(result.stock_text);
if (result.match_found == "false") {
jQuery("#notAvailable").html("Product combination not available");
jQuery(".productPrice").html(
'<span class="discounted-price">Not Enough Stock</span>'
);
jQuery(".submitToCart").prop("disabled", true);
} else {
//match found..
jQuery("#notAvailable").html("");
jQuery(".productPrice").html(result.price_content);
if (result.stock_text == "Indent") {
jQuery(".submitToCart").prop("disabled", false);
jQuery("#indentTime").html(indentTime);
jQuery("#stockStatus").html(
result.stock_text + "<br>Downpayment " + indentDp + "%"
);
} else if (result.stock_text == "In Stock") {
// jQuery('#stockStatus').html('In Stock');
jQuery(".submitToCart").prop("disabled", false);
jQuery("#indentTime").html("1-3 Days");
jQuery("#submitToCart2").attr("data-target", "#cart_madal");
} else if (result.stock_text == "No Stock") {
jQuery("#stockStatus").html("Not Enough Stock");
jQuery(".submitToCart").prop("disabled", true);
jQuery("#indentTime").html("Not Enough Stock");
jQuery("#submitToCart2").attr("data-target", "#cart_madal");
} else if (result.stock_text == "Not Available") {
jQuery("#stockStatus").html("Not Available");
jQuery(".submitToCart").prop("disabled", true);
jQuery("#indentTime").html("Not Available");
}
}
callback(result.stock_text);
//load flexslider...
loadFlexslider();
}
},
});
}
}
function changeProductDetail(
selectedDetailId,
varianOrdering,
varianId,
attributeId,
baseUrl,
productId,
indentTime,
indentDp,
callback = function (datax) {}
) {
chosenVarianDetailArray[varianOrdering - 1] = selectedDetailId;
jQuery.ajax({
url: baseUrl + "ajax/changeproductdetail",
type: "POST",
data: {
product_id: productId,
attribute_detail_id: selectedDetailId,
attribute_detail_ids: chosenVarianDetailArray,
csrftestname: csrfHash,
},
success: function (data) {
if (data) {
/*---success----*/
var result = JSON.parse(data);
jQuery("#productImageContainer").html(result.image_content);
jQuery("#detailName" + varianId).html(result.detail_attribute_name);
if (result.match_found == "false") {
jQuery("#notAvailable").html("Product combination not available");
jQuery(".productPrice").html(
'<div class="no-stock">Not Enough Stock</div>'
);
jQuery(".submitToCart").prop("disabled", true);
jQuery("#indentTime").html("Not Available");
jQuery("#stockStatus").html("Not Available");
} else {
//match found..
jQuery("#notAvailable").html("");
jQuery(".productPrice").html(result.price_content);
if (result.stock_text == "Indent") {
jQuery(".submitToCart").prop("disabled", false);
jQuery("#indentTime").html(indentTime);
// jQuery("#stockStatus").html(
// result.stock_text + "<br>Downpayment " + indentDp + "%"
// );
jQuery("#stockStatus").html(result.stock_text + " " + indentTime);
jQuery("#submitToCart2").removeAttr("data-target");
} else if (result.stock_text == "In Stock") {
// jQuery('#stockStatus').html('In Stock');
jQuery(".submitToCart").prop("disabled", false);
jQuery("#indentTime").html("1-3 Days");
jQuery("#submitToCart2").attr("data-target", "#cart_madal");
} else if (result.stock_text == "No Stock") {
jQuery("#stockStatus").html("Not Enough Stock");
jQuery(".submitToCart").prop("disabled", true);
jQuery("#indentTime").html("Not Enough Stock");
jQuery("#submitToCart2").attr("data-target", "#cart_madal");
} else if (result.stock_text == "Not Available") {
jQuery("#stockStatus").html("Not Available");
jQuery(".submitToCart").prop("disabled", true);
jQuery("#indentTime").html("Not Available");
}
}
//load flexslider...
callback(result.stock_text);
loadFlexslider();
}
},
});
}
function changeVarianColor(
varianId,
attributeId,
imageClass,
imageSpan,
varianOrdering
) {
var parent_changecolor = jQuery(
"#varian" + varianId + " ul li#" + attributeId + " a." + imageClass
);
// alert('#varian' + varianId + ' ul li#' + attributeId + ' a.' + imageClass);
parent_changecolor.on("click", function (e) {
e.preventDefault();
var t_ele = jQuery(this);
jQuery(".li_a_cvarian").removeClass("active");
t_ele.addClass("active");
jQuery("#slc_change_color").val(t_ele.data("select"));
// jQuery('#varian' + varianId + ' ul li a.' + imageClass + imageSpan).css('opacity', '0.4');
// jQuery('#varian' + varianId + ' ul li#' + attributeId + ' a.' + imageClass + imageSpan).css('opacity', '1');
var selectedDetailId = t_ele.attr("data");
changeProductDetail(
selectedDetailId,
varianOrdering,
varianId,
attributeId,
baseUrl,
productId,
indentTime,
indentDp,
function (dsc) {
dynamicStockCondition(dsc);
}
);
});
// jQuery("#slc_change_color").on('change',function(e){
// e.preventDefault();
// var t_ele = jQuery(this);
// jQuery("ul.ul_varian_color li").eq(t_ele.index()).click();
// });
}
function changeVarian(
varianId,
attributeId,
imageClass,
imageSpan,
varianOrdering
) {
jQuery(
"#varian" +
varianId +
" ul.blok_select li#" +
attributeId +
" a." +
imageClass
).on("click", function (e) {
e.preventDefault();
// jQuery('#varian' + varianId + ' ul.blok_select li a.' + imageClass + imageSpan).css('opacity', '0.4');
jQuery(".ul_varian_change_product.ul_not_color li a *").css(
"opacity",
"0.4"
);
jQuery(
"#varian" +
varianId +
" ul.blok_select li#" +
attributeId +
" a." +
imageClass +
imageSpan
).css("opacity", "1");
var selectedDetailId = jQuery(this).attr("data");
changeProductDetail(
selectedDetailId,
varianOrdering,
varianId,
attributeId,
baseUrl,
productId,
indentTime,
indentDp,
function (dsc) {
dynamicStockCondition(dsc);
}
);
});
}
// function changeVarian(varianId, attributeId, imageClass, imageSpan, varianOrdering) {
// jQuery('#varian' + varianId + ' ul.blok_select li#' + attributeId + ' a.' + imageClass).on('click', function(e) {
// e.preventDefault();
// jQuery('#varian' + varianId + ' ul.blok_select li a.' + imageClass + imageSpan).css('opacity', '0.4');
// jQuery('#varian' + varianId + ' ul.blok_select li#' + attributeId + ' a.' + imageClass + imageSpan).css('opacity', '1');
// var selectedDetailId = jQuery(this).attr('data');
// changeProductDetail(selectedDetailId, varianOrdering, varianId, attributeId, baseUrl, productId, indentTime, indentDp,
// function(dsc){
// dynamicStockCondition(dsc);
// });
// });
// }
function addToCart(chosenVarianDetailArray, qty, baseUrl, productId, csrfHash) {
jQuery.ajax({
url: baseUrl + "ajax/ajax_add_to_cart",
type: "POST",
cache: false,
data: {
product_id: productId,
qty: qty,
attribute_detail_ids: chosenVarianDetailArray,
csrftestname: csrfHash,
},
success: function (data) {
if (data) {
/*---success----*/
if (data == "no stock") {
jQuery("#stockStatus").html("Not Enough Stock");
Swal.fire({
position: "center",
// position: 'top',
icon: "warning",
text: "Not Enough Stock.",
// showConfirmButton: false,
confirmButtonText: "OK",
timer: 3000,
customClass: {
confirmButton: "btn-swal-confirm",
},
}).then((result) => {});
} else {
jQuery("#stockStatus").html("");
var cart = JSON.parse(data);
jQuery("#cart_body").html(cart.cart_content);
jQuery("#cartCount").html(cart.cart_count);
Swal.fire({
position: "center",
// position: 'top',
icon: "success",
text: "Successfully added cart.",
// showConfirmButton: false,
confirmButtonText: "OK",
timer: 3000,
customClass: {
confirmButton: "btn-swal-confirm",
},
}).then((result) => {});
}
}
},
});
}
function loadFlexslider() {
/*---------- single product big image slider ----------*/
var count_gallery_slider = $(
".shop-product__big-image-gallery-slider .single-image"
).length;
var img_centermode = true;
if (count_gallery_slider < 5) {
img_centermode = false;
}
$(".shop-product__big-image-gallery-slider").each(function () {
var $this = $(this);
var $row = $this.attr("data-row")
? parseInt($this.attr("data-row"), 10)
: 1;
$this.slick({
infinite: false,
arrows: true,
dots: true,
slidesToShow: 1,
slidesToScroll: 1,
rows: $row,
prevArrow:
'<button class="slick-prev"><i class="ti-angle-left"></i></button>',
nextArrow:
'<button class="slick-next"><i class="ti-angle-right"></i></button>',
responsive: [
{
breakpoint: 1499,
settings: {
slidesToShow: 1,
},
},
{
breakpoint: 1199,
settings: {
slidesToShow: 1,
},
},
{
breakpoint: 991,
settings: {
slidesToShow: 1,
},
},
{
breakpoint: 767,
settings: {
slidesToShow: 1,
},
},
{
breakpoint: 575,
settings: {
slidesToShow: 1,
},
},
{
breakpoint: 479,
settings: {
slidesToShow: 1,
},
},
],
});
});
/*---------- single product small image slider ----------*/
$(".shop-product__small-image-gallery-slider").each(function () {
var $this = $(this);
var $row = $this.attr("data-row")
? parseInt($this.attr("data-row"), 10)
: 1;
$this.slick({
infinite: true,
arrows: true,
dots: false,
slidesToShow: 5,
centerMode: img_centermode,
centerPadding: "15px",
slidesToScroll: 1,
rows: $row,
prevArrow:
'<button class="slick-prev"><i class="ti-angle-left"></i></button>',
nextArrow:
'<button class="slick-next"><i class="ti-angle-right"></i></button>',
asNavFor: ".shop-product__big-image-gallery-slider",
focusOnSelect: true,
responsive: [
{
breakpoint: 1499,
settings: {
slidesToShow: 5,
},
},
{
breakpoint: 1199,
settings: {
slidesToShow: 4,
},
},
{
breakpoint: 991,
settings: {
slidesToShow: 6,
},
},
{
breakpoint: 767,
settings: {
slidesToShow: 4,
},
},
{
breakpoint: 575,
settings: {
slidesToShow: 4,
},
},
{
breakpoint: 479,
settings: {
slidesToShow: 2,
},
},
],
});
});
/*---------- single product small image slider vertical ----------*/
$(".shop-product__small-image-gallery-slider--vertical").each(function () {
var $this = $(this);
var $row = $this.attr("data-row")
? parseInt($this.attr("data-row"), 10)
: 1;
$this.slick({
infinite: true,
arrows: true,
dots: false,
slidesToShow: 3,
slidesToScroll: 1,
vertical: true,
centerMode: img_centermode,
rows: $row,
prevArrow:
'<button class="slick-prev"><i class="ti-angle-left"></i></button>',
nextArrow:
'<button class="slick-next"><i class="ti-angle-right"></i></button>',
asNavFor: ".shop-product__big-image-gallery-slider",
focusOnSelect: true,
responsive: [
{
breakpoint: 1499,
settings: {
slidesToShow: 3,
},
},
{
breakpoint: 1199,
settings: {
slidesToShow: 3,
},
},
{
breakpoint: 991,
settings: {
slidesToShow: 3,
},
},
{
breakpoint: 767,
settings: {
slidesToShow: 3,
vertical: false,
arrows: false,
centerMode: true,
centerPadding: "15px",
},
},
{
breakpoint: 575,
settings: {
slidesToShow: 3,
vertical: false,
arrows: false,
centerMode: true,
centerPadding: "15px",
},
},
{
breakpoint: 479,
settings: {
slidesToShow: 2,
vertical: false,
arrows: false,
centerMode: true,
centerPadding: "15px",
},
},
],
});
});
/*---------- lightgallery and zoom activation ----------*/
//zoom
$(".shop-product__big-image-gallery-slider .single-image").zoom();
$(".shop-product__big-image-gallery-sticky .single-image").zoom();
//lightgallery
var productThumb = $(
".shop-product__big-image-gallery-slider .single-image img, .shop-product__big-image-gallery-sticky .single-image img"
),
imageSrcLength = productThumb.length,
images = [];
for (var i = 0; i < imageSrcLength; i++) {
images[i] = { src: productThumb[i].src };
}
$(".btn-zoom-popup").on("click", function () {
$(this).lightGallery({
thumbnail: false,
dynamic: true,
autoplayControls: false,
download: false,
actualSize: false,
share: false,
hash: false,
index: 0,
dynamicEl: images,
});
});
}