'; } } console.log('form'); console.log(form); $('.birthCertificateForm').html(form); $('#birthCertificateMsgBox').modal('toggle'); }); $('#birthCertificateSave').click(function(){ console.log('save'); $('#birthCertificateMsgBox').modal('toggle'); }); $('.giftcardPicker').on('click', function(e) { console.log('fdsfd'); var amount = $(this).attr('data-giftcardVal'); var qTY = $("#quantity").val(); var ProductId = $("#ProductId").val(); var amountTotal = amount * qTY; console.log(amount); console.log(qTY); console.log(amountTotal); $('#price-sales-amount').html(amountTotal); $('#giftCardVal').val(amount); let form = ''; /* if(qTY > 0) { for(var i = 1; i <= qTY; i++ ) { form += '
'; form += ''; form += ''; } } console.log('form'); console.log(form); $('#formelementsGiftcardMsg').html(form); $('#ProductGiftCardMsgBox').modal('toggle');*/ }); $('.giftcardPickerInput').on('click', function(e) { console.log('fdsfd'); var amount = $('#giftCardVal').val(); var qTY = $("#quantity").val(); var ProductId = $("#ProductId").val(); var amountTotal = amount * qTY; console.log(amount); console.log(qTY); console.log(amountTotal); $('#price-sales-amount').html(amountTotal); let form = ''; if(qTY > 0) { for(var i = 1; i <= qTY; i++ ) { form += `
`; form += ''; form += ''; } } console.log('form'); console.log(form); $('#formelementsGiftcardMsg').html(form); $('#ProductGiftCardMsgBox').modal('toggle'); }); $('#giftCardMsgSave').click(function(){ console.log('save'); var data = $('#giftcardSaveForm').serialize(); console.log(data); $.post('/ajaxcall', data, function (d) { $('#ProductGiftCardMsgBox').modal('toggle'); $('#buyProduct-'+d.productId).click(); }); }); let variantView = `
`; $('#ProductVariantBoxBody').html(variantView + '
' +$('#buyButtonForModal').html()); var change = 0; $('.quantity').on('click', '.plus', function(e) { let $input = $(this).prev('input.qty'); let val = parseInt($input.val()); $input.val( val+1 ).change(); }); $('.quantity').on('click', '.minus', function(e) { let $input = $(this).next('input.qty'); var val = parseInt($input.val()); if (val > 0) { $input.val( val-1 ).change(); } }); $('#register_wishlist_modal').click(function () { $.post('/wishlist/wishlist_logincheck', {}, function (d) { if(d.error == 1) { window.location.replace(d.url); } $('#register-wishlist').addClass('show'); $('#register-wishlist').css('display','block'); $('#register-wishlist').css('padding-right','17px'); }, 'json'); }); $('.close').click(function () { $('#product-wishlist').removeClass('show'); $('#product-wishlist').css('display','none'); $('#register-wishlist').removeClass('show'); $('#register-wishlist').css('display','none'); }); $('.close-modal').click(function () { $('#product-wishlist').removeClass('show'); $('#product-wishlist').css('display','none'); $('#register-wishlist').removeClass('show'); $('#register-wishlist').css('display','none'); }); $('#product_wishlist_modal').click(function () { let loggedIn = $('#loggedIn').val(); if(loggedIn == 1) { $.post('/wishlist/wishlist_logincheck', {}, function (d) { if(d.error == 1) { window.location.replace(d.url); } $('#product-wishlist').addClass('show'); $('#product-wishlist').css('display','block'); $('#product-wishlist').css('padding-right','17px'); }, 'json'); } else { toastr.error('Du må være innlogget for å legge varer i ønskelister.'); $('#LoginModalBox').modal('show').on('shown.bs.modal', function () { reCaptchaOnFocusModal(); }); } }); $('#save-notification').click(function(){ var parameters = {mod: 'product', action: 'inStockNotification'}; let productId = $('#ProductId').val(); parameters.productId = productId; parameters.email = $('#email').val(); $.post('/ajaxcall', parameters, function (d) { $('#register-notification').modal('toggle'); if(d.error == 1) { toastr.error(d.errorMsg); } else { $('#notify_product').hide(); } }, 'json'); }); $('#save-wishlist').click(function(){ var parameters = {mod: 'web', action: 'wishList'}; let wishListName = $('#wishlistName').val(); let productId = $('#ProductId').val(); let productName = $('#productName').val(); let wishlistComment = $('#wishlistComment').val(); let productUrl = $('#productUrl').val(); let quantity = $('#quantity').val(); parameters.wishListName = wishListName; parameters.productId = productId; parameters.quantity = quantity; parameters.productName = productName; parameters.comment = wishlistComment; parameters.productUrl = productUrl; $.post('/ajaxcall', parameters, function (d) { $('#register-wishlist').removeClass('show'); $('#register-wishlist').css('display','none'); $('.wishlist-heart').addClass('active-heart'); $('.wishlist-heart').attr("fill", "red"); toastr.success(d.success); /* reload page if this is the first wishlist in the user account */ if ($('#register_wishlist_modal').length) { window.location.reload(); } }, 'json'); }); $('#product-save-wishlist').click(function(){ var parameters = {mod: 'webProduct', action: 'wishList'}; let productId = $('#ProductId').val(); let productName = $('#productName').val(); let wishlistComment = $('#wishlistProductComment').val(); let wishlistQuantity = $('#wishlistProductQuantity').val(); let productUrl = $('#productUrl').val(); let wishListId = $('#wishlistSelect').val(); parameters.productId = productId; parameters.productName = productName; parameters.comment = wishlistComment; parameters.quantity = wishlistQuantity; parameters.productUrl = productUrl; parameters.wishListId = wishListId; $.post('/ajaxcall', parameters, function (d) { $('#product-wishlist').removeClass('show'); $('#product-wishlist').css('display','none'); console.log(d); if(d.error == 1) { toastr.error(d.errorMsg); } else if(d.response != '') { toastr.success(d.success); $('.wishlist-heart').addClass('active-heart'); $('.wishlist-heart').attr("fill", "red"); } }, 'json'); }); $('.compareProduct').click(function(){ var parameters = {mod: 'product', action: 'compare'}; let productId = $('#ProductId').val(); let productImage = $('#productImage').val(); parameters.productId = productId; $.post('/ajaxcall', parameters, function (d) { if(d.error == 1) { toastr.error(d.errorMsg); } else if(d.response != '') { if($('#comparison_container').length == 1) { let displayOutput = ''; $( "#comparison_list" ).append( displayOutput ); } else { $( d.response ).insertBefore( ".maincontent" ); } } }, 'json'); }); $('#scrollPageButton').click(function(){ var elmnt = document.getElementById("scrollContent"); elmnt.scrollIntoView(); }); $('.addon-product').change(function() { console.log('here'); var price = $(this).data( "price" ); var totalPrice = $('#price-sales-amount').data( "base-price" ); if(this.checked) { totalPrice = totalPrice + price; } else { totalPrice = totalPrice - price; } var total = totalPrice.toFixed(2); var total_display = 'kr ' + total.toString().replace(/\./g, ','); $('#price-sales-amount').text( total_display ); $('#price-sales-amount').data("base-price", totalPrice); }); var altprovals={}; $('.alternatives-product').each(function(idx,elem){ var prodid = $(this).data("id"); var price = $(this).children("[value='"+$(this).val()+"']").first().data( "price" ); altprovals[prodid] = price; }); $('.alternatives-product').change(function() { var price = $(this).children("[value='"+$(this).val()+"']").first().data( "price" ); var prodid = $(this).data("id"); var pricediff = price; if(altprovals.hasOwnProperty(prodid)) { pricediff -= altprovals[prodid]; } altprovals[prodid] = price; var totalPrice = $('#price-sales-amount').data( "base-price" ); totalPrice = totalPrice + pricediff; var total = totalPrice.toFixed(2); var total_display = 'kr ' + total.toString().replace(/\./g, ','); $('#price-sales-amount').text( total_display ); $('#price-sales-amount').data("base-price", totalPrice); }); $('.bundle-variant-select').change(function () { var selected = $(this).find('option:selected'); var cost = selected.data('extra-cost'); $(this).data('extra-cost', cost).promise().done(recalculatePrice); }); var recalculatePrice = function() { var basePrice = $('#price-sales-amount').data('base-price'); $('.bundle-variant-select').each(function (key, obj) { var optionPrice = $(obj).data('extra-cost'); basePrice += optionPrice; }); $.post('/ajaxcall', {mod: 'product', 'action': 'renderPrice', 'Price': basePrice}, function (d) { $('#price-sales-amount').html(d.ProductPrice); var ref = $('#bookingRef').attr('href'); $("#bookingRef").attr("href", ref + '&price=' + d.ProductPriceWithoutFormating); console.log(ref); }, 'json'); }; });