ДАМСКИ МАРАТОНКИ MYNDY SL FOOTWEAR
-
Марка:
-
Модел:
35709304
-
Наличност:
Изчерпан
'+$(this).find('select option:selected').text());
}
});
}
else{
checkForVariants = false;
$('.popup-buy').addClass('is-active');
}
}
prefix_option = 'Размер';
type_option = 'radio';
var selected_options = '';
var option_txt = '';
var option_text_value = '';
var selected_Val = '';
var price = 0;
var msg = '';
var num_req_fields = $( "#product .required label.control-label" ).length;
$("#product .form-group").each(function(i) {
if($(this).hasClass('required')){
console.log($(this));
console.log($(this).find('.radio input:checked').val());
if( $(this).find('.radio input:checked').val() === undefined){
alert("Моля, посочете размер.");
return false;
}
if($(this).find('.radio input:checked').val()){
option_txt = $(this).find('label.control-label').text();
option_txt = option_txt.split(':');
option_text_value = $(this).find('.radio input:checked').siblings().html();
selected_Val = $(this).find('.radio input:checked').val();
selectedOptionId = $(this).find('.radio input:checked').attr("name");
selectedOptionId = selectedOptionId.split('[')[1];
selectedOptionId = selectedOptionId.split(']')[0];
//if( $(this).find('select option:selected').attr('opt-price') ){
// price = price + parseInt( $(this).find('select option:selected').attr('opt-price').replace(' лв.', ''));
//}
selected_options+=option_txt[0]+': '+selected_Val.trim()+', ';
num_req_fields=num_req_fields-1;
console.log('radio option --> '+selected_Val +' | radio option name --> '+selectedOptionId + ' | number of req fields --> ' +num_req_fields + ' | span text --> ' + option_text_value);
} else {
option_txt = $(this).find('.radio input:checked').text();
option_txt = option_txt.split(':');
msg+=option_txt[0].toUpperCase()+', ';
$('#error_option').text(msg.substring(0,msg.length - 1));
}
}
});
if(num_req_fields==0){
checkForVariants = true;
$( "#product .required" ).each(function( i ) {
$(this).removeAttr('style');
});
} else {
var name = '';
$( "#product .required" ).each(function( i ) {
$(this).attr('style', 'color:red');
});
//error_option
checkForVariants = false;
$('.popup-buy').addClass('is-active');
updateButtonState('default');
}
if(checkForVariants){
var name = $("#namefrm").val();
var phone = $("#phonefrm").val();
var mail = $("#userMail").val();
//var quantity = $("#custom-product-count").val();
var quantity = 1;
//var address = $("#addressfrm").val();
//var city = $("#cityfrm").val();
var honeypot = $("input[name='honeypot']").val();
if (name.length< 3) {
alert("Името ви трябва да е по голямо от 3 символа.");
updateButtonState('default');
return false;
}
if (phone.length < 10 || phone.length > 10 || isNaN(phone)) {
alert("Моля въведете своя телефонен номер.");
updateButtonState('default');
return false;
}
//if(!address.length > 0){
// alert("Моля въведете адрес.");
// updateButtonState('default');
// return false;
//}
//if(!city.length > 0){
// alert("");
// updateButtonState('default');
// return false;
//}
let regexForEmail = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (!regexForEmail.test(mail)) {
alert("Моля въведете валиден имейл.");
updateButtonState('default');
return false;
}
let priceOfThis = null;
priceOfThis = $('.current-price').text();
//else {
// priceOfThis = $('.current-price').text();
//}
priceOfThis = priceOfThis.replace('лв.', '');
priceOfThis = priceOfThis.replace(',', '.');
priceOfThis = Number(priceOfThis);
$('#quick-order').prop('disabled', true);
$.post( "index.php?route=checkout/cart/quickorder", { optionPrice: price, productCount: 1, quantityOfOrder: 1, phone: $("#phonefrm").val(), mail: $("#userMail").val(), name: $("#namefrm").val(), product: 152, priceOfThis: priceOfThis, honeypot: honeypot, selected_Val : selected_Val, selectedOptionId : selectedOptionId, prefix_option : prefix_option, type_option : type_option, option_text_value : option_text_value }, function( data ) {
console.log(data);
window.location.replace("index.php?route=checkout/success");
});
}
} else {
alert('Продукта не е наличен!');
} // end check if product in stock
}