e-Gift Card 50k - The Sound Mate
Rp 50.000
e-Gift Card 50k - The Sound Mate
×
Choose Variant
Choose Variant
Tambahkan ke keranjang
Notify Me
Beli Sekarang
`;
jQuery(variationTbody).append(templateTr)
//event
setTimeout(() => {
const btnAddToCart = document.querySelector(".summary-add-to-cart")
if(btnAddToCart){
btnAddToCart.addEventListener("click", summaryAddToCartOnClick)
}
const btnMin = jQuery(".quantity-new-min")
if(btnMin){
btnMin.on("click", function(){
const currentQty = jQuery(".quantity-new").val()
if((parseInt(currentQty) - 1) == 10){
showModalAlert('Info', 'Ingin membeli dalam jumlah besar?', "bulkorder")
}
if(currentQty > 1){
const newQty = parseInt(currentQty) - 1
jQuery(".quantity-new").val(newQty)
}
})
}
const btnPlus = jQuery(".quantity-new-plus")
if(btnPlus){
btnPlus.on("click", function(){
const currentQty = jQuery(".quantity-new").val()
if((parseInt(currentQty) + 1) == 10){
showModalAlert('Info', 'Ingin membeli dalam jumlah besar?', "bulkorder")
}
if(currentQty < 300){
const newQty = parseInt(currentQty) + 1
jQuery(".quantity-new").val(newQty)
}
})
}
const btnBuyNow = document.querySelector(".summary-buy-now")
if(btnBuyNow){
btnBuyNow.addEventListener("click", summaryBuyNowOnClick)
}
}, 500);
} else {
if(variationTds.length > 0){
for (let i = 0; i < variationThs.length; i++) {
const variationTh = variationThs[i];
if(jQuery(variationTh).hasClass("label")){
let td = document.createElement('td');
td.innerHTML = `Kuantitas `
insertAfter(td, variationTh);
}
}
const templateTd = `
-
+
Buy as a Gift
Tambahkan ke keranjang
Notify Me
Beli Sekarang
`;
jQuery(variationTr).append(templateTd)
//event
setTimeout(() => {
const btnAddToCart = document.querySelector(".summary-add-to-cart")
if(btnAddToCart){
btnAddToCart.addEventListener("click", summaryAddToCartOnClick)
}
const btnMin = jQuery(".quantity-new-min")
if(btnMin){
btnMin.on("click", function(){
const currentQty = jQuery(".quantity-new").val()
if((parseInt(currentQty) - 1) == 10){
showModalAlert('Info', 'Ingin membeli dalam jumlah besar?', "bulkorder")
}
if(currentQty > 1){
const newQty = parseInt(currentQty) - 1
jQuery(".quantity-new").val(newQty)
}
})
}
const btnPlus = jQuery(".quantity-new-plus")
if(btnPlus){
btnPlus.on("click", function(){
const currentQty = jQuery(".quantity-new").val()
if((parseInt(currentQty) + 1) == 10){
showModalAlert('Info', 'Ingin membeli dalam jumlah besar?', "bulkorder")
}
if(currentQty < 300){
const newQty = parseInt(currentQty) + 1
jQuery(".quantity-new").val(newQty)
}
})
}
const btnBuyNow = document.querySelector(".summary-buy-now")
if(btnBuyNow){
btnBuyNow.addEventListener("click", summaryBuyNowOnClick)
}
}, 500);
// event bundling
function newSetBundleFromSelected(){
const selectedBundle = document.querySelector("#newSelectedBundle")
const productBundleSelected = document.querySelectorAll(".new-product-bundle.selected");
let bundleObj = {}
productBundleSelected.forEach(pbs3 => {
const obj = JSON.parse( decodeURIComponent(pbs3.dataset.obj) )
bundleObj["name"] = obj.product_name_bundling
bundleObj["description"] = obj.desc
bundleObj["variation_id"] = obj.post_id_bundling
bundleObj["image"] = obj.image_bundling
bundleObj["ean_code"] = obj.ean_code_bundling
})
if(selectedBundle){
selectedBundle.value = encodeURIComponent(JSON.stringify(bundleObj))
}
}
setTimeout(newSetBundleFromSelected, 500)
const newPbs = document.querySelectorAll(".new-product-bundle-group-product .new-product-bundle");
newPbs.forEach(function(pb){
pb.addEventListener("click", function(e){
const myTarget = e.target.parentElement
const targetProductName = myTarget.dataset.productname
const targetDescription = myTarget.dataset.description
const productName = document.querySelector(".new-product-bundle-group-product .product-bundle-product-name")
const productDescription = document.querySelector(".new-product-bundle-group-product .product-bundle-description")
productName.innerText = targetProductName
productDescription.innerHTML = targetDescription
const pbs2 = document.querySelectorAll(".new-product-bundle-group-product .new-product-bundle");
pbs2.forEach(function(pb2){
if(pb2 === myTarget){
pb2.classList.add("selected")
setTimeout(newSetBundleFromSelected, 500)
} else {
pb2.classList.remove("selected")
}
})
});
})
// end event bundling
}
}
//#endregion Summary
// check remind me on load
const productIdOnload = document.querySelector("input[name=product_id").value
const variationIdOnload = document.querySelector(".variation_id").value
const myNotifyMeOnload = document.getElementById("myNotifyMe")
const btnAddToCardOnLoad = document.querySelector(".summary-add-to-cart")
const btnBuyNowOnLoad = document.querySelector(".summary-buy-now")
const tdFullCustomizationOnLoad = document.querySelector("#tdFullCustomization")
const inputQtyOnLoad = document.querySelector(".quantity-new-container")
const labelQtyOnLoad = document.querySelector("#labelQty")
const variationsOnload = [{"variation_name":"e-Gift Card 50k - The Sound Mate - <\/span>White","color":"white","variation_id":5354,"stock_status":"instock"}];
jQuery('input.variation_id').change( function(){
if( '' != jQuery('input.variation_id').val() ) {
const var_id = jQuery('input.variation_id').val();
const findVariationOnload = variationsOnload.find(a => a.variation_id === parseInt(var_id))
if(findVariationOnload){
console.log("findVariationOnload.stock_status: ", findVariationOnload.stock_status)
if(findVariationOnload.stock_status === "outofstock"){
if(myNotifyMeOnload){
myNotifyMeOnload.style.display = "block"
if (btnAddToCardOnLoad) {
btnAddToCardOnLoad.style.display = "none"
} else {
console.log("btnAddToCardOnLoad not found")
}
if (btnBuyNowOnLoad) {
btnBuyNowOnLoad.style.display = "none"
} else {
console.log("btnBuyNowOnLoad not found")
}
// if (tdFullCustomizationOnLoad) {
// tdFullCustomizationOnLoad.style.display = "none"
// } else {
// console.log("tdFullCustomizationOnLoad not found")
// }
if (inputQtyOnLoad) {
inputQtyOnLoad.style.display = "none"
} else {
console.log("inputQtyOnLoad not found")
}
if (labelQtyOnLoad) {
labelQtyOnLoad.style.display = "none"
} else {
console.log("labelQtyOnLoad not found")
}
myNotifyMeOnload.innerText = "Stok Habis"
myNotifyMeOnload.style.background = "gray"
myNotifyMeOnload.style.pointerEvents = "none"
myNotifyMeOnload.setAttribute("disabled", "")
} else {
console.log("myNotifyMeOnload not found")
}
} else {
if (myNotifyMeOnload) {
myNotifyMeOnload.style.display = "none"
} else {
console.log("myNotifyMeOnload not found")
}
if (btnAddToCardOnLoad) {
btnAddToCardOnLoad.style.display = "block"
} else {
console.log("btnAddToCardOnLoad not found")
}
if (btnBuyNowOnLoad) {
btnBuyNowOnLoad.style.display = "block"
} else {
console.log("btnBuyNowOnLoad not found")
}
// if (tdFullCustomizationOnLoad) {
// tdFullCustomizationOnLoad.style.display = "block"
// } else {
// console.log("tdFullCustomizationOnLoad not found")
// }
if (inputQtyOnLoad) {
inputQtyOnLoad.style.display = "inline-block"
} else {
console.log("inputQtyOnLoad not found")
}
if (labelQtyOnLoad) {
labelQtyOnLoad.style.display = "block"
} else {
console.log("labelQtyOnLoad not found")
}
}
}
}
});
// end check remind me on load
// check remind me on change variation
jQuery(".variable-item").click(function(e){
const productId = document.querySelector("input[name=product_id").value
const color = e.target.getAttribute("data-value")
const variations = [{"variation_name":"e-Gift Card 50k - The Sound Mate - <\/span>White","color":"white","variation_id":5354,"stock_status":"instock"}];
const findVariation = variations.find(a => a.color === color)
const myNotifyMe = document.getElementById("myNotifyMe")
const btnAddToCard = document.querySelector(".summary-add-to-cart")
const btnBuyNow = document.querySelector(".summary-buy-now")
const tdFullCustomization = document.querySelector("#tdFullCustomization")
const inputQty = document.querySelector(".quantity-new-container")
const labelQty = document.querySelector("#labelQty")
if(myNotifyMe){
myNotifyMe.onclick = function(e){
const variationId = findVariation.variation_id
e.target.innerText = "Loading..."
e.target.style.background = "gray"
e.target.style.pointerEvents = "none"
e.target.setAttribute("disabled", "")
jQuery.ajax({
type: "POST",
url: "https://jblstore.co.id/wp-admin/admin-ajax.php",
data: {
action: "ajax_get_product_remind_me",
product_id: productId,
variation_id: variationId,
current_url: window.location.href
},
success: function(data){
const dataJson = JSON.parse(data);
if(dataJson.redirect){
window.location.href = dataJson.redirect
}
if(dataJson.is_remind_me){
e.target.innerText = "Cancel Notify Me"
e.target.style.background = "linear-gradient(251.5deg, #F04C24 46.51%, #F88D2A 99.75%)"
e.target.style.pointerEvents = "auto"
e.target.removeAttribute("disabled")
} else {
e.target.innerText = "Notify Me"
e.target.style.background = "linear-gradient(251.5deg, #F04C24 46.51%, #F88D2A 99.75%)"
e.target.style.pointerEvents = "auto"
e.target.removeAttribute("disabled")
}
}
})
}
if(findVariation){
if(findVariation.stock_status === "outofstock"){
if(myNotifyMe){
myNotifyMe.style.display = "block"
btnAddToCard.style.display = "none"
btnBuyNow.style.display = "none"
// tdFullCustomization.style.display = "none"
inputQty.style.display = "none"
labelQty.style.display = "none"
const variationId = findVariation.variation_id
myNotifyMe.innerText = "Stok Habis"
myNotifyMe.style.background = "gray"
myNotifyMe.style.pointerEvents = "none"
myNotifyMe.setAttribute("disabled", "")
}
} else {
if(myNotifyMe){
myNotifyMe.style.display = "none"
btnAddToCard.style.display = "block"
btnBuyNow.style.display = "block"
// tdFullCustomization.style.display = "block"
inputQty.style.display = "inline-block"
labelQty.style.display = "block"
}
}
}
}
})
// end check remind me on change variation
// on click notify me
// end on click notify me
})
-->