$( function() { $("#completa-ordine").click(function() { if ( parseInt( $('#ordine_acquistabile').val() ) > 0 ) { if( fCheckObbligatori() ) fSaveData(); } else swal( "Warning!", "The order is not available.", "error" ); }); $('input[name=scelta]').change(function() { $('.label_scelta span').removeClass('active'); if ( $(this).val() == 'registrazione' ) { $('#label_scelta_registrazione span').addClass('active'); $('.row-nessuna-registrazione-box').addClass('hide'); $('.row-registrazione-box').removeClass('hide'); $('#registra-newsletter').prop('checked', true); $('#txtPassword').focus(); } else { $('#label_scelta_nessuna_registrazione span').addClass('active'); $('.row-registrazione-box').addClass('hide'); $('.row-nessuna-registrazione-box').removeClass('hide'); $('#registra-newsletter').prop('checked', false); $('.fg-txtPassword, .fg-txtConfermaPassword').removeClass('has-error'); $('#lbltxtPassword, #lbltxtConfermaPassword').html(''); } }); $('input[name=pagamento]').change(function() { $('#totale_ordine_loader').removeClass('hide'); $('.scegli-pagamento-radio label > span').removeClass('active'); $('.pagamento_descrizione').addClass('hide'); var pagid = $(this).val(); if ( $(this).prop('checked') ) { $( '#pagamento_span_' + pagid ).addClass('active'); $( '.pagamento_descrizione_' + pagid ).removeClass('hide'); } fAggiornaTotaleOrdine(); $('#totale_ordine_loader').addClass('hide'); }); // tipo_registrazione $('.tipo_registrazione').change(function() { if ( $('.tipo_registrazione:checked').val() == 'azienda' ) { // AZIENDA $('.fg-txtRagioneSociale').removeClass('hide'); $('#col-codicefiscale').addClass('hide'); $('#col-partitaiva').removeClass('hide'); } else { // PRIVATO $('.fg-txtRagioneSociale').addClass('hide'); $('#col-codicefiscale').addClass('hide'); $('#col-partitaiva').addClass('hide'); } }); // nazione $('#cmbNazione').change(function() { if ( $(this).val() == 'IT' ) { $('#label_ricarica_postepay, #label_vaglia, #label_contrassegno').removeClass('hide'); $('#col-citta').removeClass('col-md-8').addClass('col-md-4'); $('#col-provincia').removeClass('hide'); $('#col-codicefiscale').removeClass('hide'); } else { $('.panel-spedizione').addClass('hide'); $('#label_ricarica_postepay, #label_vaglia, #label_contrassegno').addClass('hide'); if ( $("input[name=pagamento]:checked").val() == 'ricarica_postepay' || $("input[name=pagamento]:checked").val() == 'vaglia' || $("input[name=pagamento]:checked").val() == 'contrassegno' ) { $('.scegli-pagamento-radio label > span').removeClass('active'); $('.pagamento_descrizione').addClass('hide'); $('#pagamento_paypal').prop('checked', true); $( '#pagamento_span_paypal' ).addClass('active'); $( '.pagamento_descrizione_paypal' ).removeClass('hide'); } $('#col-provincia').addClass('hide'); $('#col-citta').removeClass('col-md-4').addClass('col-md-8'); $('#col-codicefiscale').addClass('hide'); } $.ajax({ type: "POST", async: false, dataType: "json", url: "/tpl/default/assets/ajax/setCarrello.php", data: "action=checkSpedizioniBloccate&pstrNazione=" + $('#cmbNazione').val(), success: function(data) { if ( parseInt( data.spedizioni_bloccate ) > 0 ) { $('#crl_spedizione_box').addClass('hide'); } else { $('#crl_spedizione_box').removeClass('hide'); } } }); /* ajax */ fAggiornaTotaleOrdine(); }); // provincia $('#cmbProvincia').change(function() { fAggiornaTotaleOrdine(); $('.desc_foggia').addClass('hide'); if ( $(this).val() == 'Foggia' ) { $('#desc_foggia').removeClass('hide'); } else if ( $(this).val() == 'Foggia1' ) { $('#desc_foggia1').removeClass('hide'); } else if ( $(this).val() == 'Foggia2' ) { $('#desc_foggia2').removeClass('hide'); } }); $('.email-continua').click(function() { var blnReturn = true; if ( $('#txtEmail').val() != '' ) { $('.rblock').addClass('hide'); $('#loader-login').removeClass('hide'); $( ".fg-txtEmail" ).removeClass( "has-error" ); $('#lbltxtEmail').html(''); $('#ciao-cliente').html( '' ); var data; var strAlert = ""; $.ajax({ type: "POST", async: false, dataType: "json", url: "/tpl/default/assets/ajax/checkContatto.php", data: "action=checkEmailCarrello&pstrEmail=" + $('#txtEmail').val(), success: function(data) { $('#loader-login').addClass('hide'); if ( data.email_check == 0 ) { // Email non corretta if ( data.email_errore == 2 ) { // ERRORE : email NON esiste blnReturn = false; $('#lbltxtEmail').html( fHTMLErrore( "The address does not exist" ) ); $( ".fg-txtEmail" ).addClass( "has-error" ); if ( strAlert == "" ) strAlert = "The address does not exist"; } else if ( data.email_errore == 1 ) { // ERRORE : email NON corretta blnReturn = false; $('#lbltxtEmail').html( fHTMLErrore( "The address is not correct" ) ); $( ".fg-txtEmail" ).addClass( "has-error" ); if ( strAlert == "" ) strAlert = "The address is not correct"; } } else { // Email corretta if ( data.email_exists == 1 ) { // ERRORE : email già in archivio $('.rblock').addClass('hide'); $('.rblock-login').removeClass('hide'); $('#ciao-cliente').html( 'Hi ' + data.nome + ',
enter your password to access the site:

' ); } else { // OK : Email unica, corretta e non in archivio $('.rblock-login').addClass('hide'); $('.rblock').removeClass('hide'); $('#scelta_registrazione').prop('checked',true); $('#registra-newsletter').prop('checked',true); } } } }); /* ajax */ } else { $('#txtEmail').focus(); } if ( ! blnReturn && strAlert != "" ) { swal("Warning!", strAlert, "error"); } return false; }); $('#procedi_senza_login').click(function() { $('.rblock-login').addClass('hide'); $('.rblock').removeClass('hide'); $('.row-scelta-registrazione, .row-scelta-registrazione-box').addClass('hide'); $('#scelta_nessuna_registrazione').prop('checked', true); $('#registra-newsletter').prop('checked', false); $('#ciao-cliente').html( '' ); }); $('#but_login').click(function() { $('#submitButLogin').addClass('hide'); $('#submitLoadLogin').removeClass('hide'); $( ".fg-txtEmail" ).removeClass( "has-error" ); $( "#lbltxtEmail" ).html(""); $( ".fg-txtPasswordLogin" ).removeClass( "has-error" ); $( "#lbltxtPasswordLogin" ).html(""); if ( $.trim( $('#txtEmail').val() ) == '' ) { $( ".fg-txtEmail" ).addClass( "has-error" ); $( "#lbltxtEmail" ).html("Required"); $( "#txtEmail" ).focus(); } else if ( $.trim( $('#txtPasswordLogin').val() ) == '' ) { $( ".fg-txtPasswordLogin" ).addClass( "has-error" ); $( "#lbltxtPasswordLogin" ).html("Required"); $( "#txtPasswordLogin" ).focus(); } else { var data; var strDestination = ''; var blnSaved = false; $.ajax({ type: "POST", async: false, dataType: "json", url: "/tpl/default/assets/ajax/loginCliente.php", data: "lang_current=en&txtUsernameCliente=" + $("#txtEmail").val() + "&txtPasswordCliente=" + $("#txtPasswordLogin").val(), success: function(data) { strDestination = data.destination; if ( data.status == 'ok' ) blnSaved = true; else swal("Ops...", "Unable to perform the operation.", "error"); }, error: function(data) { swal("Ops...", "Procedure completed.", "error"); } }); /* ajax */ if ( blnSaved ) { if ( strDestination != '' ) { location.href = strDestination; } else { $('#submitLoadLogin').addClass('hide'); $('#submitButLogin').removeClass('hide'); $('#loginErrore').removeClass('hide'); fLoading( 0 ); } } else { $('#submitLoadLogin').addClass('hide'); $('#submitButLogin').removeClass('hide'); } } }); $('input[name=radioAssicurata]').change(function() { fAggiornaTotaleOrdine(); }); $('#verifica_codice_sconto').click(function() { $('#row-sconto-carrello').addClass('hide'); $('#sconto_carrello_descrizione, #sconto_carrello_label').html( '' ); $('#sconto_carrello').val( 0 ); $('#codice_sconto_carrello').val( '' ); $('.fg-txtCodiceScontoInput').removeClass('has-error'); if ( $.trim( $('#txtCodiceScontoInput').val() ) == '' ) { $('.fg-txtCodiceScontoInput').addClass('has-error'); $('#txtCodiceScontoInput').focus(); } else { $('.panel-hai-un-codice').addClass('hide'); $('.panel-hai-un-codice-loader').removeClass('hide'); var data; var blnVerifica = false; var strLabelTop = ""; var strLabel = ""; var strLabelType = ""; $.ajax({ type: "POST", async: false, dataType: "json", url: "/tpl/default/assets/ajax/setCodiceSconto.php", data: "action=setCodiceSconto&id_cliente=" + $("#id_cliente").val() + "&codice_sconto=" + $('#txtCodiceScontoInput').val() + "&lang_current=" + $('#lang_current').val(), success: function(data) { $('#hai-un-codice-loader').addClass('hide'); if ( data.status == 'ok' ) { if ( data.verifica > 0 ) { blnVerifica = true; $('#sconto_carrello_descrizione').html( data.sconto_descrizione ); $('#sconto_carrello_label').html( data.sconto_valore_label ); $('#sconto_carrello').val( data.sconto_valore ); $('#codice_sconto_carrello').val( data.codice ); $('#row-sconto-carrello').removeClass('hide'); $('#codice_success_label').html( data.sconto_success_label ); strLabelTop = "Ok"; strLabel = "Lo sconto è stato inserito correttamente."; strLabelType = "success"; } else { strLabelTop = data.label_top; strLabel = data.label; strLabelType = data.label_type; } } else { swal("Ops...", "Unable to perform the operation.", "error"); } }, error: function(data) { swal("Ops...", "Procedure completed.", "error"); } }); fAggiornaTotaleOrdine(); $('.panel-hai-un-codice-loader').addClass('hide'); if ( blnVerifica ) $('.panel-hai-un-codice-success').removeClass('hide'); else $('.panel-hai-un-codice').removeClass('hide'); if ( strLabelTop != "" ) swal( strLabelTop, strLabel,strLabelType ); } }); $('#rimuovi_codice_sconto').click(function() { $('.panel-hai-un-codice-success').addClass('hide'); $('.panel-hai-un-codice-loader').removeClass('hide'); $('#row-sconto-carrello').addClass('hide'); $('#sconto_carrello_descrizione, #sconto_carrello_label').html( '' ); $('#sconto_carrello').val( 0 ); $('#codice_sconto_carrello').val( '' ); $('#txtCodiceScontoInput').val( '' ); fAggiornaTotaleOrdine(); $('.panel-hai-un-codice-loader').addClass('hide'); $('.panel-hai-un-codice').removeClass('hide'); swal( "Ok", "Lo sconto è stato rimosso.", "success" ); }); }); function fAggiornaTotaleOrdine() { $('#totale_ordine_loader').removeClass('hide'); var data; var strID_Pagamento = $("input[name=pagamento]:checked").val(); var strNazione = $("#cmbNazione").val(); if ( strNazione == '' ) strNazione = 'IT'; $.ajax({ type: "POST", async: false, dataType: "json", url: "/tpl/default/assets/ajax/setCarrello.php", data: "action=setTotaleCarrello&id_cliente=" + $("#id_cliente").val() + "&provincia=" + $("#cmbProvincia").val() + "&nazione=" + strNazione + "&id_pagamento=" + strID_Pagamento + "&sconto=" + $("#sconto_carrello").val() + "&totale_peso=" + $("#totale_peso").val() + "&assicurata_con=" + ( $("#radioAssicurata_assicurata").prop('checked') ? 1 : 0 ) + "&pstrLangCurrent=" + $("#lang_current").val() + "&totale_carrello_prodotti=" + $("#totale_carrello_prodotti").val(), success: function(data) { if ( data.status == 'ok' ) { $('#costo_spedizione').val( data.spedizione_totale ); $('#costo_spedizione_standard').val( data.spedizione_costo_db ); $('#costo_spedizione_assicurata').val( data.assicurazione_db ); $('#crl_contrassegno').html( data.contrassegno_costo ); /*$('#crl_spedizione_label').html( data.spedizione_label ); $('#crl_spedizione_costo_label').html( data.spedizione_costo ); $('#crl_paypal_commissioni').html( data.paypal_commissioni ); $('#crl_totale_label').html( data.totale_ordine );*/ $('.crl_spedizione_label').html( data.spedizione_label ); $('.crl_spedizione_totale_label').html( data.spedizione_totale_label ); if ( parseInt( data.ordine_acquistabile ) > 0 ) { //if ( data.spedizione_costo_db > 0 ) $('.crl_spedizione_standard').html( '+ € ' + data.spedizione_costo ); //else $('.crl_spedizione_standard').html( '  FREE' ); //if ( data.spedizione_totale > 0 ) $('.crl_spedizione_costo_label').html( data.spedizione_totale_format ); //else $('.crl_spedizione_costo_label').html( 'FREE' ); $('.crl_costo_assicurata').html( '€ ' + data.assicurazione ); $('.spedizione_nondisponibile_provincia').addClass('hide'); $('.spedizione_nondisponibile').addClass('hide'); $('.assicurata_box').removeClass('hide'); } else if ( $("#cmbNazione").val() == 'IT' && $.trim( $("#cmbProvincia").val() ) == '' ) { $('.crl_spedizione_costo_label').html( 'choose province' ); $('.assicurata_box').addClass('hide'); $('.spedizione_nondisponibile').addClass('hide'); $('.spedizione_nondisponibile_provincia').removeClass('hide'); } else { $('.crl_spedizione_costo_label').html( 'not available' ); $('.spedizione_nondisponibile_provincia').addClass('hide'); $('.assicurata_box').addClass('hide'); $('.spedizione_nondisponibile').removeClass('hide'); } $('#crl_imponibile').html( '€' + data.imponibile ); $('#crl_totale_label').html( '€' + data.totale_ordine ); $('#ordine_acquistabile').val( parseInt( data.ordine_acquistabile ) ); if ( strID_Pagamento == 'contrassegno' && ! parseInt( data.has_contrassegno_free ) ) $('#row-contrassegno').removeClass('hide'); else $('#row-contrassegno').addClass('hide'); /*if ( parseInt( data.spedizione_bloccata ) > 0 ) { $('#spedizione_non_disponibile').removeClass('hide'); $('#completa-ordine').addClass('hide'); $('#completa-ordine-blocked-spedizione').removeClass('hide'); } else { $('#spedizione_non_disponibile').addClass('hide'); $('#completa-ordine-blocked-spedizione').addClass('hide'); $('#completa-ordine').removeClass('hide'); }*/ } else swal("Ops...", "Unable to perform the operation.", "error"); }, error: function(data) { swal("Ops...", "Procedure completed.", "error"); } }); if ( strID_Pagamento == 'contrassegno' ) $('#row-contrassegno').removeClass('hide'); else $('#row-contrassegno').addClass('hide'); if ( strID_Pagamento == 'paypal' || strID_Pagamento == 'carta' || strID_Pagamento == 'postepay' ) $('#row-paypal-commissioni').removeClass('hide'); else $('#row-paypal-commissioni').addClass('hide'); $('#totale_ordine_loader').addClass('hide'); } function fSaveData() { $('submit').focus(); $('#submitBut').addClass('hide'); $('#submitLoad').removeClass('hide'); var data; var strDestination = ''; var strID_Ordine = ''; var strPagamento = ''; var blnSaved = false; $.ajax({ type: "POST", async: false, dataType: "json", url: "/tpl/default/assets/ajax/sendOrder.php", data: $("#frmCompletaOrdine").serialize(), success: function(data) { strPagamento = data.pagamento; if ( data.status == 'obbligatori' ) $('#completaErrore').removeClass('hide'); else $('#completaErrore').addClass('hide'); if ( data.status == 'ok' ) { blnSaved = true; if ( parseInt( data.nuovo_cliente ) > 0 ) fbq('track', 'CompleteRegistration' ); fbq('track', 'Purchase', { value: data.totale_ordine, currency: 'EUR', content_type: 'product', content_ids: [ $('#facebook_content_ids').val() ] }); strID_Ordine = data.id_ordine; } else if ( data.status == 'spedizioni_bloccate' ) { swal("Warning!", "For shipping outside of Europe please contact our staff for a quote, thanks.", "warning"); } else swal("Ops...", "Unable to perform the operation.", "error"); }, error: function(data) { swal("Ops...", "Procedure completed.", "error"); } }); if ( blnSaved && strID_Ordine != '' ) { if ( strPagamento == 'paypal' ) { // PAGAMENTO PAYPAL fLoading( 1 ); $('#frameAcquista').attr( 'src', '/include/paypal_form2.php?lang_current=en&id_ordine=' + strID_Ordine + '&pagamento=' + $("input[name=pagamento]:checked").val() ); } else { location.href = '/en/order-sent/'; } } else { $('#submitLoad').addClass('hide'); $('#submitBut').removeClass('hide'); } } // Controllo campi obbligatori function fCheckObbligatori() { var blnReturn = true; var strAlert = ""; $('submit').focus(); $('#submitBut').addClass('hide'); $('#submitLoad').removeClass('hide'); $( ".form-group, .fg-txtRecapito1" ).removeClass( "has-error" ); $( ".lbl" ).html(""); var sceltaRegistrazione = $('#scelta_registrazione').prop('checked'); var strID_Contatto = ( $('#id_cliente').length ? $('#id_cliente').val() : '' ); // Controllo email if ( $("#txtEmail").val() != '' ) { $('#loader-email').removeClass('hide'); $('#lbltxtEmail').html( '' ); var intErrore = ''; $.ajax({ type: "POST", async: false, dataType: "json", url: "/tpl/default/assets/ajax/checkEmail.php", data: "action=checkEmail&pstrEmail=" + $("#txtEmail").val(), success: function(data) { intErrore = data.errore; if ( intErrore == 1 ) { // ERRORE : email NON corretta blnReturn = false; $('#lbltxtEmail').html( fHTMLErrore( "The address is not correct." ) ); $( ".fg-txtEmail" ).addClass( "has-error" ); strAlert = "L'email non è corretta."; } else if ( intErrore == 2 ) { // ERRORE : email NON esiste blnReturn = false; $('#lbltxtEmail').html( fHTMLErrore( "The address does not exists" ) ); $( ".fg-txtEmail" ).addClass( "has-error" ); strAlert = "L'email non esiste."; } if ( data.status == 'errore' ) blnSaved = false; else if ( data.status == 'ok' ) blnSaved = true; else swal("Ops...", "Verification failed", "error"); }, error: function(data) { swal("Ops...", "Procedure completed.", "error"); } }); } $('.required').each(function() { if ( $.trim( $(this).val() ) == "" ) { blnReturn = false; $( "#lbl" + $(this).attr("name") ).html( fHTMLErrore( "Required field" ) ); $( ".fg-" + $(this).attr("name") ).addClass( "has-error" ); if ( strAlert == "" ) if ( $(this).attr("name") == "txtEmail" ) strAlert = "Enter your email address and click on continue to enter data for shipment."; else strAlert = "Enter the field: " + $( "#lbl" + $(this).attr("name") ).attr("title"); } else $( "#lbl" + $(this).attr("name") ).html(""); }); // Controllo provincia if ( $('#cmbNazione').val() == 'IT' && $.trim( $('#cmbProvincia').val() ) == '' ) { blnReturn = false; $('#lblcmbProvincia').html( fHTMLErrore( "" ) ); $( ".fg-cmbProvincia" ).addClass( "has-error" ); if ( strAlert == "" ) strAlert = "Enter the province"; } else $('#lblcmbProvincia').html(""); if ( $('#scelta_registrazione').prop('checked') ) { // Controllo password if ( $.trim( $('#txtPassword').val() ) == '' ) { blnReturn = false; $("#lbltxtPassword").html( fHTMLErrore( "Required field" ) ); $(".fg-txtPassword").addClass( "has-error" ); if ( strAlert == "" ) strAlert = "Enter the password"; } else $("#lbltxtPassword").html(""); if ( $.trim( $('#txtConfermaPassword').val() ) == '' ) { blnReturn = false; $("#lbltxtConfermaPassword").html( fHTMLErrore( "Required field" ) ); $(".fg-txtConfermaPassword").addClass( "has-error" ); if ( strAlert == "" ) strAlert = "Confirm the password"; } else $("#lbltxtConfermaPassword").html(""); if ( $('#txtPassword').val() != '' || $('#txtConfermaPassword').val() != '' ) { if ( $('#txtPassword').val() != $('#txtConfermaPassword').val() ) { blnReturn = false; $('#lbltxtConfermaPassword').html( fHTMLErrore( "The password is not 'the same." ) ); $( ".fg-txtConfermaPassword" ).addClass( "has-error" ); if ( strAlert == "" ) strAlert = "The password is not equal."; } else $('#lbltxtConfermaPassword').html(""); } } // Controllo privacy if( ! $('#privacy').prop('checked') ) { blnReturn = false; $('#lblprivacy').html( fHTMLErrore( "Acceptance required." ) ); $( ".fg-privacy" ).addClass( "has-error" ); if ( strAlert == "" ) strAlert = "The acceptance of the privacy policy is mandatory"; } else $('#lblprivacy').html(""); // Controllo RagioneSociale if ( $('.tipo_registrazione:checked').val() != 'privato' ) { if ( $.trim( $('#txtRagioneSociale').val() ) == "" ) { blnReturn = false; $( "#lbltxtRagioneSociale" ).html( fHTMLErrore( "Required" ) ); $( ".fg-txtRagioneSociale" ).addClass( "has-error" ); if ( strAlert == "" ) strAlert = "Enter your company name"; } else { $( "#lbltxtRagioneSociale" ).html(""); } } var blnEstero = ( $('#cmbNazione').val() != 'IT' ? true : false ); //; // Controllo Codice fiscale if ( ! blnEstero && $('.tipo_registrazione:checked').val() == 'privato' ) { if ( $.trim( $('#txtCodiceFiscale').val() ) == "" ) { blnReturn = false; $( "#lbltxtCodiceFiscale" ).html( fHTMLErrore( "Required" ) ); $( ".fg-txtCodiceFiscale" ).addClass( "has-error" ); if ( strAlert == "" ) strAlert = "Enter your tax code"; } else { $( "#lbltxtCodiceFiscale" ).html(""); $('#lbltxtCodiceFiscale').html( '' ); var data; var intExists = 0; var blnSaved = false; $.ajax({ type: "POST", async: false, dataType: "json", url: "/tpl/default/assets/ajax/checkContatto.php", data: "action=checkCodiceFiscale&pstrCodiceFiscale=" + $("#txtCodiceFiscale").val() + "&pstrID_Contatto=" +strID_Contatto, success: function(data) { intExists = data.codice_fiscale_exists; if ( intExists == 1 && ! $('#scelta_nessuna_registrazione').prop('checked') ) { // ERRORE : valore NON unico blnReturn = false; $('#lbltxtCodiceFiscale').html( fHTMLErrore( "The value already exist." ) ); $( ".fg-txtCodiceFiscale" ).addClass( "has-error" ); if ( strAlert == "" ) strAlert = "The tax code is already on file"; } else { // OK : valore unico $('#lbltxtCodiceFiscale').html(""); } if ( data.status == 'ok' ) blnSaved = true; else swal("Ops...", "LNG_AJAX_VERIFICA", "error"); }, error: function(data) { swal("Ops...", "Procedure uncompleted.", "error"); } }); } } // Controllo Partita IVA if ( $('.tipo_registrazione:checked').val() != 'privato' ) { if ( $.trim( $('#txtPartitaIva').val() ) == "" ) { blnReturn = false; $( "#lbltxtPartitaIva" ).html( fHTMLErrore( "Required" ) ); $( ".fg-txtPartitaIva" ).addClass( "has-error" ); if ( strAlert == "" ) strAlert = "Enter your VAT code"; } else { $( "#lbltxtPartitaIva" ).html(""); $('#lbltxtPartitaIva').html( '' ); var data; var intExists = 0; var blnSaved = false; $.ajax({ type: "POST", async: false, dataType: "json", url: "/tpl/default/assets/ajax/checkContatto.php", data: "action=checkPartitaIva&pstrPartitaIva=" + $("#txtPartitaIva").val() + "&pstrID_Contatto=" +strID_Contatto, success: function(data) { intExists = data.partita_iva_exists; if ( intExists == 1 && ! $('#scelta_nessuna_registrazione').prop('checked') ) { // ERRORE : valore NON unico blnReturn = false; $('#lbltxtPartitaIva').html( fHTMLErrore( "The value already exist." ) ); $( ".fg-txtPartitaIva" ).addClass( "has-error" ); if ( strAlert == "" ) strAlert = "The VAT code is already on file"; } else { // OK : valore unico $('#lbltxtPartitaIva').html(""); } if ( data.status == 'ok' ) blnSaved = true; else swal("Ops...", "LNG_AJAX_VERIFICA", "error"); }, error: function(data) { swal("Ops...", "Procedure uncompleted.", "error"); } }); } } $('#submitLoad').addClass('hide'); $('#submitBut').removeClass('hide'); if ( ! blnReturn ) { $('#completaErrore').removeClass('hide'); if ( strAlert != "" ) swal("Warning!", strAlert, "error"); } else $('#completaErrore').addClass('hide'); return blnReturn; } function fHTMLErrore( pstr ) { return '' + pstr + ''; } // Aggiorna quantita function fAggiornaQuantita( pstrKey, pintID_Riga ) { fLoading( 1 ); var pintQuantita = $('#quantita_'+pintID_Riga).val(); $.ajax({ type: "POST", async: false, dataType: "json", url: "/tpl/default/assets/ajax/setCarrello.php", data: "action=aggiornaQuantita&pstrKey=" + pstrKey + "&pintID_Riga=" + pintID_Riga + "&pintQuantita=" + pintQuantita, success: function(data) { if ( data.status == 'ok' ) { location.href = '/en/cart/' + ( data.max == 'exceed' ? '?max=exceed' : '' ); } else swal("Ops...", "Unable to perform the operation.", "error"); }, error: function(data) { swal("Ops...", "Procedure completed.", "error"); } }); /* ajax */ } // Rimuovi prodotto function fDelProd( pstrKey, pintID_Riga ) { swal({ title: "Warning!", text: "Remove this product from the cart?", type: "warning", showCancelButton: true, cancelButtonText: "No, cancel", confirmButtonText: "Yes, delete!", closeOnConfirm: true }, function() { fLoading( 1 ); $.ajax({ type: "POST", async: false, dataType: "json", url: "/tpl/default/assets/ajax/setCarrello.php", data: "action=rimuoviProdotto&pstrKey=" + pstrKey + "&pintID_Riga=" + pintID_Riga, success: function(data) { if ( data.status == 'ok' ) { location.href = '/en/cart/'; } else swal("Ops...", "Unable to perform the operation.", "error"); }, error: function(data) { swal("Ops...", "Procedure completed.", "error"); } }); /* ajax */ }); } // Svuota carrello function fSvuotaCarrello( pstrKey ) { swal({ title: "Warning!", text: "Remove all products from the cart?", type: "warning", showCancelButton: true, cancelButtonText: "No, cancel", confirmButtonText: "Yes, delete!", closeOnConfirm: true }, function() { fLoading( 1 ); $.ajax({ type: "POST", async: false, dataType: "json", url: "/tpl/default/assets/ajax/setCarrello.php", data: "action=svuotaCarrello&pstrKey=" + pstrKey, success: function(data) { if ( data.status == 'ok' ) { location.href = '/en/cart/'; } else swal("Ops...", "Unable to perform the operation.", "error"); }, error: function(data) { swal("Ops...", "Procedure completed.", "error"); } }); /* ajax */ }); }