// document.write(""); // lightbox.option({ // 'disableScrolling': false, // 'fitImagesInViewport': false // }) $(function () { //セレクトボックスが切り替わったら発動 $('select[name^="select_item"]').change(function () { var sum_price = 0; var total_count = getItemTotalCount(); if (!is_login) { if (mk_show_price == '1') { $('.pricetext').text("¥***"); return; } if (mk_show_price == '2') { if (total_count > 4) { $('.pricetext').text("¥***"); return; } } } // selectタグすべてを取得してループ $('select[name^="select_item"]').each(function () { // 選択されている値を取得して var item_count = $(this).val(); var item_size = $(this).attr('data-size'); var item_price = arr_kakaku[item_size] * parseInt(item_count, 10); if (total_count > 4) { item_price = arr_kakaku5[item_size] * parseInt(item_count, 10); } // 合計計算 sum_price += item_price; }); $('#kingaku').text("¥" + sum_price.toLocaleString()); }); $('#addbutton').click(function () { var total_count = getItemTotalCount(); console.log(total_count); if (total_count == "0") { $('.pricetext').text("商品の個数を選択してください"); return false; } else { $('#c-item').submit(); } }); function getItemTotalCount() { var total_count = 0; $('select[name^="select_item"]').each(function () { var item_count = $(this).val(); total_count += parseInt(item_count, 10); }); return total_count; } }); // /**5個以上の価格表示にログインが必要な商品の場合**/ function myFormatNumber(x) { var s = "" + x; var p = s.indexOf("."); if (p < 0) { p = s.length; } var r = s.substring(p, s.length); for (var i = 0; i < p; i++) { var c = s.substring(p - 1 - i, p - 1 - i + 1); if (c < "0" || c > "9") { r = s.substring(0, p - i) + r; break; } if (i > 0 && i % 3 == 0) { r = "," + r; } r = c + r; } return r; } function show_price() { // $("#addbutton").prop("disabled", false); var count = document.getElementsByName("count[]"); var len = count.length; var total_count = 0; var tmp_price = document.getElementById("kingaku"); for (i = 1; i < len + 1; i++) { tmp = parseInt(count[i - 1].value); total_count += tmp; } if (document.getElementById) { var goukei = 0; var tmp = 0; for (i = 1; i < len + 1; i++) { tmp = parseInt(count[i - 1].value); var js_tmp_price = document.getElementById('price_text' + i); if (!is_login) { if (mk_show_price == '1') { // alert("※この商品の価格は、\nユーザー登録された方にのみお知らせしています。"); price_text = document.querySelectorAll("[id^=price_text]"); for (var i = 0; i < price_text.length; i++) { price_text[i].innerHTML = "¥***"; } tmp_price.innerHTML = "***"; // $("#addbutton").prop("disabled", true); return; } } if (total_count >= 5) { if (!is_login) { if (mk_show_price != '0') { // alert("※この商品の御買上数量5以上の価格は、\nユーザー登録された方にのみお知らせしています。"); price_text = document.querySelectorAll("[id^=price_text]"); for (var i = 0; i < price_text.length; i++) { price_text[i].innerHTML = "¥***"; } tmp_price.innerHTML = "***"; // $('#addbutton').prop("disabled", true); return; } } var r_tmp = arr_kakaku5[i - 1]; var c_tmp = tmp; js_tmp_price.innerHTML = "¥" + myFormatNumber(r_tmp); } else { var r_tmp = arr_kakaku[i - 1]; var c_tmp = tmp; js_tmp_price.innerHTML = "¥" + myFormatNumber(r_tmp); } goukei += r_tmp * c_tmp; } tmp_price.classList.add('pricetext-lg'); tmp_price.innerHTML = "¥" + myFormatNumber(goukei); } } function registFavorite(b1_code, user_code, item_code) { if (b1_code == "" || user_code == "" || item_code == "") { if (user_code == "") { alert("ログインしてからボタンを押してください。ユーザー登録されていない方は、登録の上ログインしてください。"); } return; } location.href = '../user/regist_favorite.php' + '?b1_code=' + b1_code + '&user_code=' + user_code + '&item_code=' + item_code; } function itemCountCheck() { var count = document.getElementsByName("count[]"); var len = count.length; var total_count = 0; for (i = 1; i < len + 1; i++) { tmp = parseInt(count[i - 1].value); total_count += tmp; } if (total_count == "0") { target = document.getElementById("kingaku"); target.classList.remove('pricetext-lg'); target.innerHTML = "商品の個数を選択してください"; return false; } else { return true; } } //-->