MENU
- #ブラシ刻印
- #定期便
- #コラボ
- #誕生日リップ
- #eギフト
\ ' } var cartItems;function makeCartTags(tempCartItems){ let list_tags = ""; let loop_idx = 1; let item_count = 0; let isSubscription = false; let subscriptionCount = 0; let hideDiscountSkuString = null; let hideDiscountSkus = hideDiscountSkuString?.split('\n'); for (key in tempCartItems) { item = tempCartItems[key]; if(hideDiscountSkus != undefined) { if(item.properties && item.properties['プラン名'] && !hideDiscountSkus.includes(item.sku)){ subscriptionCount += item.quantity; } } } for (key in tempCartItems) { item = tempCartItems[key]; if (item.tag_gwp < 0) { item_count += item.quantity; } list_tag = makeTrRow(); list_tag = replaceHtmlTag(loop_idx, item, list_tag,subscriptionCount); list_tags += list_tag; loop_idx++ if(item.selling_plan_allocation){ isSubscription = true; } } if(isSubscription){ }else{ $("#subscription-discount").html(''); $("#subscription-attention").html(''); } $(".not-empty-popup-area").append(list_tags); $(".cart-count-bubble span:first-child").html(item_count); $("cart-drawer").trigger("click"); } function getProduct(cartItems) { let cart_item_length = cartItems.length; let tempCartItems = new Array(); for (let idx = 0; idx < cart_item_length; idx++) { let item = ""; item = cartItems[idx]; jQuery.ajax({ type: 'get', url: '/products/' + item.handle + '.js', dataType: 'json' }) .then(function (response) { //cartItems[key]product_tags = 1; let product = response; //alert(product.title); let tag_gwp = $.inArray('GWP', product.tags); item.tag_gwp = tag_gwp; tempCartItems.push(item); if (tempCartItems.length == cart_item_length) { makeCartTags(tempCartItems); } hideSkuEffect(); }); } } function getCart() { jQuery.ajax({ type: 'get', url: '/cart.js', dataType: 'json' }) .then(function (response) { cartNote = response.note; var cart_special_instructions = document.getElementById('CartSpecialInstructions'); if (cart_special_instructions && cart_special_instructions.length > 0) { cart_special_instructions.value = cartNote; } cartObject = response; if (!cartObject.item_count) { $(".empty-popup-area").show(); $(".not-empty-popup-area").hide(); $(".not-empty").hide(); $(".l-header__head-cart-count").html(0); return false; } else { $(".empty-popup-area").hide(); $(".not-empty-popup-area").show(); $(".not-empty").show(); } $(".not-empty-popup-area").empty(); $("#cart_total_price").html(Shopify.formatMoney(cartObject.total_price * tax, "¥{{amount_no_decimals}}")); rounded_total_price = cartObject.total_price * tax; let shipping_add = parseInt('550') * 100; let amount_allow_free_shipping = parseInt('3980') * 100; let hasSellingPlanAllocation = (cartObject.items || []).some(item => item.selling_plan_allocation && item.selling_plan_allocation !== null); let has_free_shipping = 'false' === "true" || hasSellingPlanAllocation; if (amount_allow_free_shipping <= rounded_total_price || has_free_shipping) { $("#free_shipping_tag").show(); $("#not_free_shipping_tag").hide(); } else { $("#free_shipping_tag").hide(); $("#not_free_shipping_tag").show(); rounded_total_price += (shipping_add * 1); } $("#rounded_total_price").html(Shopify.formatMoney(rounded_total_price, "¥{{amount_no_decimals}}")); cartItems = cartObject.items; cartItems.sort( compare );//Todo sort getProduct(cartItems); }) } function replaceHtmlTag(loop_idx, item, list_tag,subscriptionCount){ list_tag = list_tag.replace(/%%line_item.product.url%%/g, item.url); //セット商品以外 let hide_class_name = ''; if (item.tag_gwp >= 0) { hide_class_name = 'gwp_hidden'; } list_tag = list_tag.replace(/%%hide_class_name%%/g, hide_class_name); if (item.featured_image != undefined) { image_url = item.featured_image.url.replace(/https:/g, ""); list_tag = list_tag.replace(/%%line_item.product.image%%/g, image_url); list_tag = list_tag.replace(/%%line_item.product.alt%%/g, item.featured_image.alt); } list_tag = list_tag.replace(/%%line_item.product.title%%/g, item.title); list_tag = list_tag.replace(/%%line_item.key%%/g, item.key); list_tag = list_tag.replace(/%%line_item.variant_id%%/g, item.variant_id); list_tag = list_tag.replace(/%%forloop.index%%/g, loop_idx); price = Shopify.formatMoney(item.price * tax, "¥{{amount_no_decimals}}"); //console.log(item.price) list_tag = list_tag.replace(/%%line_item.product.price%%/g, price); list_tag = list_tag.replace(/%%line_item.product.handle%%/g, item.handle); list_tag = list_tag.replace(/%%line_item.variant.sku%%/g, item.sku); list_tag = list_tag.replace(/%%line_item.variant.selling_plan_allocation%%/g, item.selling_plan_allocation ? "true" : "false"); option_tags = ""; for (i = 1; i <= 12; i++){ option_tag = makeVariantPullDown(i, item); option_tags += option_tag; } list_tag = list_tag.replace(/%%makeVariantPullDown%%/g, option_tags); let propertiesHtml = ""; if(item.properties && item.properties['フォント']){ propertiesHtml += `
刻印サービス
フォント:${item.properties['フォント']}
テキスト:${item.properties['テキスト']}
`; } if(item.properties && item.properties['プラン名']){ propertiesHtml += `
定期お届け便
お届けサイクル【${item.properties['プラン名']}】
`; propertiesHtml += `
`; } list_tag = list_tag.replace(/%%properties%%/g, propertiesHtml); return list_tag; } // バリアント削除 function removeTrClicked(key) { data = {quantity:0,id:key} $.ajax({ type: "POST", url: '/cart/change.js', data: data, dataType:"json", }).then(r => { //成功時 getCart(); }); }document.addEventListener("DOMContentLoaded", function(){ // 数量変更 $(document).on("change", ".quantity_pull", function () { let quantity = $(this).val(); let key = $(this).data("key"); data = {quantity:quantity,id:key} $.ajax({ type: "POST", url: '/cart/change.js', data: data, dataType:"json", }).then(function (response) { //成功時 getCart(); }) .catch((e) => { }); }); var tags = ["20250214launch","johnmastersorganics","price_5000","seasonal-gift","valentine2025","ジョンマスターオーガニック","ヘアケア","ランキング"]; var disableButton = ()=>{ var thisObj = $(".radio__variant:checked"); var price = thisObj.attr('data-price'); var sku = thisObj.attr('data-sku'); var stock = thisObj.attr('data-stock'); var checkTrackInventory = thisObj.attr('data-check-track-inventory'); var intPrice = parseInt(price.replace(",",""),10); intPrice = Math.floor(intPrice * 0.9); $('#product__price__box_subscription').text("¥" + intPrice.toLocaleString()); if (tags && tags.includes("stop-selling-"+sku)){ if(stock<=0 && checkTrackInventory =="shopify"){ $("button#add[type='submit']:not(.stop-selling)").attr('disabled', true); $("button#add_sm[type='submit']:not(.stop-selling)").attr('disabled', true); $("button#add[type='submit']:not(.stop-selling)").hide(); $("button#add[type='button']:not(.stop-selling)").hide(); $("button#add_sm[type='submit']:not(.stop-selling)").hide(); $("button#add_sm[type='button']:not(.stop-selling)").hide(); $('#select_inventory_quantity').hide();$('#BIS_trigger').show();$('.product-infobox #BIS_trigger').show(); }else{ $("button#add[type='submit']:not(.stop-selling)").attr('disabled', true); $("button#add_sm[type='submit']:not(.stop-selling)").attr('disabled', true); $("button#add[type='submit']:not(.stop-selling)").hide(); $("button#add[type='button']:not(.stop-selling)").show(); $("button#add_sm[type='submit']:not(.stop-selling)").hide(); $("button#add_sm[type='button']:not(.stop-selling)").show(); $('#select_inventory_quantity').hide();$('#BIS_trigger').hide();$('.product-infobox #BIS_trigger').hide(); } }else{ if(stock<=0 && checkTrackInventory =="shopify"){ $("button#add[type='submit']:not(.stop-selling)").attr('disabled', true); $("button#add_sm[type='submit']:not(.stop-selling)").attr('disabled', true); $("button#add[type='submit']:not(.stop-selling)").hide(); $("button#add[type='button']:not(.stop-selling)").hide(); $("button#add_sm[type='submit']:not(.stop-selling)").hide(); $("button#add_sm[type='button']:not(.stop-selling)").hide(); $('#select_inventory_quantity').hide(); $('#BIS_trigger').show();$('.product-infobox #BIS_trigger').show(); }else{ $("button#add[type='submit']:not(.stop-selling)").attr('disabled', false); $("button#add_sm[type='submit']:not(.stop-selling)").attr('disabled', false); $("button#add[type='submit']:not(.stop-selling)").show(); $("button#add[type='button']:not(.stop-selling)").hide(); $("button#add_sm[type='submit']:not(.stop-selling)").show(); $("button#add_sm[type='button']:not(.stop-selling)").hide(); $('#select_inventory_quantity').show(); $('#BIS_trigger').hide();$('.product-infobox #BIS_trigger').hide(); } } if(tags && tags.includes("stop-subscription-"+sku)){ $("div#add-subscription").hide(); $("button#discontinued:not(.stop-subscription)").show(); $('#select_subscription_inventory_quantity').hide(); }else{ $("div#add-subscription").show(); $(".subscription button#discontinued:not(.stop-subscription)").hide(); $('#select_subscription_inventory_quantity').show(); } } disableButton(); $(".radio__variant").click(function () { if ($('.radio__variant').is(':checked')) { disableButton(); let variantId = $(this).val(); if (variantId) { let url = new URL(window.location.href); url.searchParams.set('variant', variantId); window.history.pushState({}, '', url.toString()); } } }); // get variant let url = new URL(window.location.href); let variantId = url.searchParams.get('variant'); if (variantId) { const selected = $(`.radio__variant[value="${variantId}"]`); selected.attr('checked', 'checked'); selected.click(); }});