* Em compras a partir de '+ jsonPO.show_in_cash_discount +'
'; cash_discount_alert = '*'; if ($('.product-price-discount .discount_simulator').length){ cash_discount = ' * Em compras a partir de '+ jsonPO.show_in_cash_discount +''; } } prefix = ''; square = false; /*ANCHOR - parametros das parcelas*/ let parcelData = { 'parcel_quantity': jsonPO.parcel_simulator, 'parcel_price': jsonPO.price_simulator, }; /*ANCHOR - parametros para mostrar valores com e/ou sem juros*/ if(jsonPO.show_interest_installment == 2){ parcelData['show_both_parcels']= true; parcelData['parcel_no_interest_quantity']= jsonPO.no_interest_installments; parcelData['parcel_no_interest_price']= jsonPO.price_simulator_no_interest; }else{ parcelData['text_interest'] = text_interest; } /*ANCHOR - parametros para mostrar valor total a se pagar da parcela*/ if(jsonPO.special){ if(!square) { $('.product-prices-content .product-price-old').html('De ' + jsonPO.price + prefix); $('.product-prices-content .product-price-new').html(` Por ${jsonPO.special} ${prefix} ${jsonPO.payment_type ? ''+ jsonPO.payment_type+ '' : '' } `); } if($('.square-calculate-price span').length > 0) { $('.square-calculate-price span').html(jsonPO.special); } if(jsonPO.special_discount){ if($('.product-prices-content .product-price-discount .discount_simulator').length){ $('.product-prices-content .product-price-discount').html(' ou '+ jsonPO.special_discount +'à vista ' + text_special_porcent + text_discount + cash_discount_alert +''+ cash_discount); } else{ $('.product-prices-content .product-price-discount').html(' ou '+ jsonPO.special_discount +'à vista' + text_discount + cash_discount_alert + cash_discount); } } }else{ if(!square) { $('.product-prices-content .product-main-price').html(jsonPO.price + prefix); } if($('.square-calculate-price span').length > 0) { $('.square-calculate-price span').html(jsonPO.price); } if(jsonPO.price_discount){ if($('.product-prices-content .product-price-discount .discount_simulator').length){ $('.product-prices-content .product-price-discount').html(' ou '+jsonPO.price_discount+' à vista ' + text_special_porcent + text_discount + cash_discount_alert +''+ cash_discount); } else{ $('.product-prices-content .product-price-discount').html(' ou '+jsonPO.price_discount+' à vista ' + text_special_porcent + text_discount + cash_discount_alert + cash_discount); } } } alterParcel(parcelData); if(option_points){ $('.product-reward-points>strong:first-child').text(option_points); } if(json.price_attacked && json.attacked_status){ $('.product-prices-content .product-price-attacked:not(.min-attacked)').html('Preço de Atacado: ' + json.price_attacked + ''); } /* ANCHOR Preço unitário - simulate*/ if(unit_price && unit_price_special == ""){ $('.multiple-sales-price.text-dark').text(unit_price); } else if(unit_price_special){ $('.multiple-sales-price.text-dark').text(`De ${unit_price}`); $('h2.multiple-sales-price').text(`Por ${unit_price_special}`); } $('.placeholder-glow, .placeholder').removeClass('placeholder-glow placeholder'); }, complete: function(){ setTimeout(() => { $('.button-cart').button('reset'); }, 500); }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log(XMLHttpRequest.responseText); }, }); } function validateNumber(input) { let min = parseFloat(input.attr("min")) || null; let max = parseFloat(input.attr("max")) || null; let step = Number(input.attr("step")) || 1; let value = parseFloat(input.val()); if (isNaN(value)) { value = 0; } else if (min || max) { if (max !== null) { value = Math.min(value, max); } if (min !== null) { value = Math.max(value, min); value = Math.round((value - min) / step) * step + min; } } input.val(value); } $('[data-toggle="popover"]').click(function(){ if (!$(this).find('input[name="quantity_grid"]').length) { priceOptionClick(); } }); $('.grid_remove_selected').click(function () { $(this).parent().removeClass('selected'); $(this).parent().removeClass('grid_selected'); $(this).parent().find('input[name="quantity"]').val(0); $(this).parent().find('input[name="quantity"]').trigger('change'); return false; }); /* Adição e Subtração */ $('#input-square').change(function() { priceOptionClick('square_package'); }); $('#input-quantity:not([type="hidden"])').change(function() { priceOptionClick('quantity'); }); }); $('.product-number #input-quantity').blur(function(){ quantity_value = $('.product-number #input-quantity').val(); if(quantity_value <= 0 || quantity_value == ''){ $('.product-number #input-quantity').val(1); } }); var clear_time; var smartHintEnabled = 0; $('#button-quote_product').on('click', function () { var quantity = $('input[type="number"][name="quantity"]').val(); if (!quantity) { quantity = 1; } total_stock_quantity = 1; if ($('.sizes.selected').length) { var product_option_value_id_size = $('.sizes.selected').attr('data-product-option-value-id'); } else { var product_option_value_id_size = 0; } let width = '10.00'; let height = '10.00'; let price; let weight; let price_without_currency; if($('#sticker_price').val() && $('#sticker_weight').val()) { price = $('#sticker_price').val(); weight = $('#sticker_weight').val(); price_without_currency = price; } else { price = '249.9'; weight = '0.3500'; price_without_currency = '249.90'; } var params = { "postcode": $('input[name=\'postcode\']').val(), "product_id": '4201', "weight": weight, "width": width, "height": height, "days_stock": '30', "price": price, "price_without_currency": price_without_currency, "product_special_price": '', "price_special_type": '', "special_percent": '', "special_payment_method": '', "quantity_product": quantity, "product_option_value_id_size" : product_option_value_id_size, form: {} }; $('#product input[type=\'text\']').each(function(){ if ($(this).val()) { params['form'][$(this).attr('name')] = $(this).attr('data-product-option-id'); } }); $('#product input[type=\'hidden\']:not(.buy-together-opt)').each(function(){ if ($(this).val()) { params['form'][$(this).attr('name')] = $(this).val(); } }); $('#product input[type=\'radio\']:checked').each(function(){ if ($(this).val()) { params['form'][$(this).attr('name')] = $(this).val(); } }); $('#product input[type=\'checkbox\']:checked').each(function(){ if ($(this).val()) { params['form'][$(this).attr('name')] = $(this).val(); } }); $('#product select:not(.buy-together-opt)').each(function(){ if ($(this).val()) { params['form'][$(this).attr('name')] = $(this).val(); } }); $('#product textarea').each(function(){ if ($(this).val()) { params['form'][$(this).attr('name')] = $(this).val(); } }); var postcodeLength = 9; if($('input[name=postcode]').val().length < postcodeLength){ $('#modal-shipping').empty(); $('#modal-shipping').html('
Para poder realizar o calculo do frete escolha seu numero e a quantidade desejada. '); if (smartHintEnabled == 0) { $('#button-quote_product').button('loading'); $('#button-quote_product').button('reset'); } clearTimeout(clear_time); clear_time = setTimeout(function(){ $('#modal-shipping').fadeOut('slow', function(){ $(this).empty(); $(this).show(); }); }, 5000); } else { $.ajax({ url: 'index.php?route=module/shipping/simulate', type: 'post', data: params , dataType: 'json', beforeSend: function () { if (smartHintEnabled == 0) { $('#button-quote_product').button('loading'); } $('
Carregando informações de envio
').insertAfter('.postcode-inputs'); }, complete: function () { if (smartHintEnabled == 0) { $('#button-quote_product').button('reset'); } $('.shipping-load-message').remove(); }, success: function (json) { $('#modal-shipping').empty(); $('#shipping-error').empty(); $('.alert, .text-danger, .simulate_shipping_methods, #shipping-error').remove(); if (json['error']) { if (json['error']['warning']) { $('#shipping-error').remove(); $('#shipping-content').append('
x
' + json['error']['warning'] + '
'); } if (json['error']['postcode']) { $('#shipping-content').append('
' + json['error']['postcode'] + '
'); } if (json['error']['error_quote_simulation']) { $('#modal-shipping').empty(); $('#modal-shipping').html('
Erro ao recuperar políticas de frete, tente novamente mais tarde. '); } } if (json['shipping_method']) { html = '
'; html += '
x
'; html_error = ''; for (i in json['shipping_method']) { if (!json['shipping_method'][i]['error']) { for (j in json['shipping_method'][i]['quote']) { if(j == 'frete_rapido'){ for (k in json['shipping_method'][i]['quote'][j]) { html += '
'; html += ''; html += '
'; if(json['shipping_method'][i]['quote'][j][k]['info']){ html += ''+json['shipping_method'][i]['quote'][j][k]['info']+''; } } } else if (j == 'mandae'){ for (k in json['shipping_method'][i]['quote'][j]) { html += '
'; html += ''; html += json['shipping_method'][i]['quote'][j][k]['title'] + ' - ' + json['shipping_method'][i]['quote'][j][k]['text']; html += ' '+json['shipping_method'][i]['quote'][j][k]['delivery_time']+''; html += ''; html += '
'; if(json['shipping_method'][i]['quote'][j][k]['info']){ html += ''+json['shipping_method'][i]['quote'][j][k]['info']+''; } if(json['shipping_method'][i]['quote'][j][k]['error']){ html += ''+json['shipping_method'][i]['quote'][j][k]['error']+''; } } } else if (j == 'jadlog_api'){ for (k in json['shipping_method'][i]['quote'][j]) { html += '
'; html += ''; html += json['shipping_method'][i]['quote'][j][k]['title'] + ' - ' + json['shipping_method'][i]['quote'][j][k]['text']; html += ' '+json['shipping_method'][i]['quote'][j][k]['delivery_time']+''; html += ''; html += '
'; if(json['location_jadlogPickup']){ if(json['shipping_method'][i]['quote'][j][k]['jadlog_label'] == 'PICKUP'){ html += `
Locais para retirada Jadlog Pickup
`; $.map( json['location_jadlogPickup'], function( n, i ) { html += `
${n['name_stablishment']}
Endereço: ${n['addres']}
Horario de Funcionamento: ${n['time_avaliable']}
${n['saturday']}
${n['sunday']}
Estacionamento: ${n['parking']}
`; }); html += `
`; } } if(json['shipping_method'][i]['quote'][j][k]['info']){ html += ''+json['shipping_method'][i]['quote'][j][k]['info']+''; } if(json['shipping_method'][i]['quote'][j][k]['error']){ html += ''+json['shipping_method'][i]['quote'][j][k]['error']+''; } } } else if (j == 'melhor_envio'){ for (k in json['shipping_method'][i]['quote'][j]) { html += '
'; html += ''; html += json['shipping_method'][i]['quote'][j][k]['title'] + ' - ' + json['shipping_method'][i]['quote'][j][k]['text']; html += ' '+json['shipping_method'][i]['quote'][j][k]['delivery_time']+''; html += ''; html += '
'; if(json['shipping_method'][i]['quote'][j][k]['info']){ html += ''+json['shipping_method'][i]['quote'][j][k]['info']+''; } if(json['shipping_method'][i]['quote'][j][k]['error']){ html += ''+json['shipping_method'][i]['quote'][j][k]['error']+''; } } } else if (j == 'onlog'){ for (k in json['shipping_method'][i]['quote'][j]) { html += '
'; html += ''; html += json['shipping_method'][i]['quote'][j][k]['title'] + ' - ' + json['shipping_method'][i]['quote'][j][k]['text']; html += ' '+json['shipping_method'][i]['quote'][j][k]['delivery_time']+''; html += ''; html += '
'; if(json['shipping_method'][i]['quote'][j][k]['info']){ html += ''+json['shipping_method'][i]['quote'][j][k]['info']+''; } if(json['shipping_method'][i]['quote'][j][k]['error']){ html += ''+json['shipping_method'][i]['quote'][j][k]['error']+''; } } } else if (j == 'posta_ja'){ for (k in json['shipping_method'][i]['quote'][j]) { html += '
'; html += ''; html += json['shipping_method'][i]['quote'][j][k]['title'] + ' - ' + json['shipping_method'][i]['quote'][j][k]['text']; html += ' '+json['shipping_method'][i]['quote'][j][k]['delivery_time']+''; html += ''; html += '
'; if(json['shipping_method'][i]['quote'][j][k]['info']){ html += ''+json['shipping_method'][i]['quote'][j][k]['info']+''; } if(json['shipping_method'][i]['quote'][j][k]['error']){ html += ''+json['shipping_method'][i]['quote'][j][k]['error']+''; } } } else if (j == 'neomode'){ for (k in json['shipping_method'][i]['quote'][j]) { html += '
'; html += ''; html += json['shipping_method'][i]['quote'][j][k]['title'] + ' - ' + json['shipping_method'][i]['quote'][j][k]['text']; html += ' '+json['shipping_method'][i]['quote'][j][k]['delivery_time']+''; html += ''; html += '
'; if(json['shipping_method'][i]['quote'][j][k]['info']){ html += ''+json['shipping_method'][i]['quote'][j][k]['info']+''; } if(json['shipping_method'][i]['quote'][j][k]['error']){ html += ''+json['shipping_method'][i]['quote'][j][k]['error']+''; } } } else if (j == 'frete_q'){ for (k in json['shipping_method'][i]['quote'][j]) { html += '
'; html += ''; html += json['shipping_method'][i]['quote'][j][k]['title'] + ' - ' + json['shipping_method'][i]['quote'][j][k]['text']; html += ' '+json['shipping_method'][i]['quote'][j][k]['delivery_time']+''; html += ''; html += '
'; if(json['shipping_method'][i]['quote'][j][k]['info']){ html += ''+json['shipping_method'][i]['quote'][j][k]['info']+''; } if(json['shipping_method'][i]['quote'][j][k]['error']){ html += ''+json['shipping_method'][i]['quote'][j][k]['error']+''; } } } else if (j == 'rodoe'){ for (k in json['shipping_method'][i]['quote'][j]) { html += '
'; html += ''; html += json['shipping_method'][i]['quote'][j][k]['title'] + ' - ' + json['shipping_method'][i]['quote'][j][k]['text']; html += ' '+json['shipping_method'][i]['quote'][j][k]['delivery_time']+''; html += ''; html += '
'; if(json['shipping_method'][i]['quote'][j][k]['info']){ html += ''+json['shipping_method'][i]['quote'][j][k]['info']+''; } if(json['shipping_method'][i]['quote'][j][k]['error']){ html += ''+json['shipping_method'][i]['quote'][j][k]['error']+''; } } } else if (j == 'frenet'){ for (k in json['shipping_method'][i]['quote'][j]) { html += '
'; html += ''; html += json['shipping_method'][i]['quote'][j][k]['title'] + ' - ' + json['shipping_method'][i]['quote'][j][k]['text']; html += ' '+json['shipping_method'][i]['quote'][j][k]['delivery_time']+''; html += ''; html += '
'; if(json['shipping_method'][i]['quote'][j][k]['info']){ html += ''+json['shipping_method'][i]['quote'][j][k]['info']+''; } if(json['shipping_method'][i]['quote'][j][k]['error']){ html += ''+json['shipping_method'][i]['quote'][j][k]['error']+''; } } } else if (j == 'data_frete') { for (k in json['shipping_method'][i]['quote'][j]) { html += '
'; html += ''; html += json['shipping_method'][i]['quote'][j][k]['title'] + ' - ' + json['shipping_method'][i]['quote'][j][k]['text']; html += ' '+json['shipping_method'][i]['quote'][j][k]['delivery_time']+''; html += ''; html += '
'; if(json['shipping_method'][i]['quote'][j][k]['info']){ html += ''+json['shipping_method'][i]['quote'][j][k]['info']+''; } if(json['shipping_method'][i]['quote'][j][k]['error']){ html += ''+json['shipping_method'][i]['quote'][j][k]['error']+''; } } } else if (j == 'intelipost') { for (k in json['shipping_method'][i]['quote'][j]) { html += '
'; html += ''; html += json['shipping_method'][i]['quote'][j][k]['title'] + ' - ' + json['shipping_method'][i]['quote'][j][k]['text']; html += ' '+json['shipping_method'][i]['quote'][j][k]['delivery_time']+''; html += ''; html += '
'; if(json['shipping_method'][i]['quote'][j][k]['info']){ html += ''+json['shipping_method'][i]['quote'][j][k]['info']+''; } if(json['shipping_method'][i]['quote'][j][k]['error']){ html += ''+json['shipping_method'][i]['quote'][j][k]['error']+''; } } } else if (j == 'smart_envios') { for (k in json['shipping_method'][i]['quote'][j]) { html += '
'; html += ''; html += json['shipping_method'][i]['quote'][j][k]['title'] + ' - ' + json['shipping_method'][i]['quote'][j][k]['text']; html += ' '+json['shipping_method'][i]['quote'][j][k]['delivery_time']+''; html += ''; html += '
'; if(json['shipping_method'][i]['quote'][j][k]['info']){ html += ''+json['shipping_method'][i]['quote'][j][k]['info']+''; } if(json['shipping_method'][i]['quote'][j][k]['error']){ html += ''+json['shipping_method'][i]['quote'][j][k]['error']+''; } } } else if (j == 'kangu') { for (k in json['shipping_method'][i]['quote'][j]) { if (json['shipping_method'][i]['quote'][j][k]['title'] && json['shipping_method'][i]['quote'][j][k]['text'] && json['shipping_method'][i]['quote'][j][k]['delivery_time']) { html += '
'; html += ''; html += json['shipping_method'][i]['quote'][j][k]['title'] + ' - ' + json['shipping_method'][i]['quote'][j][k]['text']; html += ' '+json['shipping_method'][i]['quote'][j][k]['delivery_time']+''; html += ''; html += '
'; if(json['shipping_method'][i]['quote'][j][k]['info']){ html += ''+json['shipping_method'][i]['quote'][j][k]['info']+''; } if(json['shipping_method'][i]['quote'][j][k]['error']){ html += ''+json['shipping_method'][i]['quote'][j][k]['error']+''; } } } } else if (j == 'rede_sul' || j == 'ipost') { for (k in json['shipping_method'][i]['quote'][j]) { html += '
'; html += ''; html += json['shipping_method'][i]['quote'][j][k]['title'] + ' - ' + json['shipping_method'][i]['quote'][j][k]['text']; html += ' '+json['shipping_method'][i]['quote'][j][k]['delivery_time']+''; html += ''; html += '
'; if(json['shipping_method'][i]['quote'][j][k]['info']){ html += ''+json['shipping_method'][i]['quote'][j][k]['info']+''; } if(json['shipping_method'][i]['quote'][j][k]['error']){ html += ''+json['shipping_method'][i]['quote'][j][k]['error']+''; } } } else if (j == 'mandou_chegou') { for (k in json['shipping_method'][i]['quote'][j]) { html += '
'; html += ''; html += json['shipping_method'][i]['quote'][j][k]['title'] + ' - ' + json['shipping_method'][i]['quote'][j][k]['text']; html += ' '+json['shipping_method'][i]['quote'][j][k]['delivery_time']+''; html += ''; html += '
'; if(json['shipping_method'][i]['quote'][j][k]['info']){ html += ''+json['shipping_method'][i]['quote'][j][k]['info']+''; } if(json['shipping_method'][i]['quote'][j][k]['error']){ html += ''+json['shipping_method'][i]['quote'][j][k]['error']+''; } } } else if (j == 'correios_api'){ for (k in json['shipping_method'][i]['quote'][j]) { html += '
'; html += ''; html += json['shipping_method'][i]['quote'][j][k]['title'] + ' - ' + json['shipping_method'][i]['quote'][j][k]['text']; html += ' '+json['shipping_method'][i]['quote'][j][k]['delivery_time']+''; html += ''; html += '
'; if(json['shipping_method'][i]['quote'][j][k]['info']){ html += ''+json['shipping_method'][i]['quote'][j][k]['info']+''; } if(json['shipping_method'][i]['quote'][j][k]['error']){ html += ''+json['shipping_method'][i]['quote'][j][k]['error']+''; } if(json['shipping_method'][i]['quote'][j][k]['msgPrazo']){ html += ''+json['shipping_method'][i]['quote'][j][k]['msgPrazo']+''; } } } else if (j == 'super_frete'){ for (k in json['shipping_method'][i]['quote'][j]) { html += '
'; html += ''; html += json['shipping_method'][i]['quote'][j][k]['title'] + ' - ' + json['shipping_method'][i]['quote'][j][k]['text']; html += ' '+json['shipping_method'][i]['quote'][j][k]['delivery_time']+''; html += ''; html += '
'; if(json['shipping_method'][i]['quote'][j][k]['info']){ html += ''+json['shipping_method'][i]['quote'][j][k]['info']+''; } } } else if(j == 'clique_retire_correios') { let data = json['shipping_method'][j]; let address = data.quote.clique_retire_correios.locations.address; let name = data.quote.clique_retire_correios.locations.name; html += '
'; html += ''; html += json['shipping_method'][i]['quote'][j]['title'] + ' - ' + json['shipping_method'][i]['quote'][j]['text']; html += ' '+json['shipping_method'][j]['delivery_time']+''; html += ' '+name+''; html += ' '+address+''; html += ''; html += '
'; } else { html += '
'; html += ''; html += json['shipping_method'][i]['quote'][j]['title'] + ' - ' + json['shipping_method'][i]['quote'][j]['text']; html += ' '+json['shipping_method'][j]['delivery_time']+''; html += ''; html += '
'; if(json['shipping_method'][j]['quote']){ for(quote_info in json['shipping_method'][j]['quote']){ html += ''+json['shipping_method'][j]['quote'][quote_info]['info']+''; } } if(json['shipping_method'][i]['quote'][j]['code'] == 'pickup.pickup'){ for (k in json['shipping_method'][i]['locations']){ html += '' + json['shipping_method'][i]['locations'][k]['address'] + ''; } } let is_undefined = typeof json['shipping_method'][i]['quote'][j]['msgPrazo'] !== 'undefined'; if (json['shipping_method'][i]['quote'][j]['msgPrazo'] != '' && is_undefined){ for (k in json['shipping_method'][i]['quote']){ html += '' + json['shipping_method'][i]['quote'][k]['msgPrazo'] + ''; } } } } } else { if ((i == 'sedex' || i == 'pac') && html_error.search(json['shipping_method'][i]['quote'][i]['msgErro']) == -1) { if (json['shipping_method']['sedex'] == undefined || json['shipping_method']['pac'] == undefined) { html_error += '
'); clearTimeout(clear_time); clear_time = setTimeout("$('#error-insert').fadeOut();", 5000); } }); } if(!error_select_option){ if($('#input-quantity').hasClass('packageTrigger')){ $('.packageTrigger').trigger('click'); return; } addCart(); } }); $('button[id^=\'button-upload\']').on('click', function (event) { var node = $(this); var option_id = node.data('upload-option-id'); $('#form-upload').remove(); $('body').prepend(''); $('#form-upload input[name=\'file\']').trigger('click'); $('#form-upload').on('change', function(){ if ($('#form-upload input[name=\'file\']').val() != '') { $.ajax({ url: 'index.php?route=tool/upload&upload-option-id=' + node.data('upload-option-id'), type: 'post', dataType: 'json', data: new FormData($('#form-upload')[0]), cache: false, contentType: false, processData: false, beforeSend: function () { if (smartHintEnabled == 0) { $(node).button('loading'); } }, success: function (json) { $('.text-danger').remove(); $('.alert-success').remove(); if (json['error']) { if (smartHintEnabled == 0) { $(node).button('reset'); } $(node).parent().find('input').after('
' + json['error'] + '
'); } if (json['success']) { swal(json.success); var str = json.filename; var res = str.slice(-4); if(str.length > 30){ var res2 = str.slice(0, 15); } else{ var res2 = str.slice(0, (str.length / 2)); } $(node).html(res2 + '(...)' + res).addClass('btn btn-success').removeClass('disabled').removeAttr('disabled'); $(node).parent().find('input').attr('value', json['code']); } }, error: function (xhr, ajaxOptions, thrownError) { console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } }); } }); }); var product_package = 'on'; $('.packageTrigger').click(function(){ if($(this).find('span.grid_remove_selected').length == 1){ return false; } var product_option_id = $(this).data('product-option-id'); var product_option_value_id = $(this).data('product-option-value-id'); var product_id = $(this).attr('data-product-id'); var product_package_term = 'O produto em questão será fabricado e enviado de acordo como prazo informado.'; /*Quando o cliente utiliza a ordem de compra do produto e o mesmo possui um prazo para retornar ao estoque*/ $.ajax({ url: 'index.php?route=product/product/checkPurchaseOption&product_option_value_id=' + product_option_value_id + '&product_id=' + product_id, dataType: 'json', async: false, success: function (json) { if(json.success){ product_package_term = json.success; } } }); $('.button-cart').removeClass('animated tada'); swal({ title: 'Produto Sob Encomenda', html: '
'+product_package_term+'
', type: 'warning', showCancelButton: true, confirmButtonColor: '#61a642', cancelButtonColor: '#d33', confirmButtonText: 'Eu aceito', cancelButtonText: 'Não concordo', }).then(function(result){ if (result.value) { swal({ title : 'Produto Adicionado Com Sucesso!', html: '
Fique atento ao prazo de produção, qualquer dúvida entre em contato
', type: 'success', showConfirmButton: false, timer: 3000, onClose: function() { var animate = 0; if($('.options_list').find('.required').length){ $('.options_list').find('.required').each(function(index, el) { if($(this).find('.selected').length === 0){ animate = 1; } }); }else{ addCart(); } if(animate === 1 && !$('.uniqueInputValue').val()){ $('.button-cart').addClass('animated tada'); } else{ if($('.options_list').find('.required').length){ addCart() } } } }); } else { swal({ title : 'O Produto Não foi Adicionado ao Carrinho', html: '
Qualquer duvida permanecemos a disposição
', type: 'error', showConfirmButton: false, timer: 3000, onClose: function() { $('.options_list').find('.inputcheck.packageTrigger').prop('checked', false); $('.product-floating').find('.inputfloating.packageTrigger').prop('checked', false); $('input[data-product-option-value-id="' + product_option_value_id + '"]').removeClass('selected').prop('checked', false); $('.text-danger').remove(); $('#input-option' + product_option_id).val(''); } }); } }) }); $('.options-list textarea, .options-list input[type="text"]').focusout(function(){ $(this).parent().removeClass('has-error'); $(this).siblings('.alert').remove(); $('.product-option-warning').remove(); }); $('select[name=\'recurring_id\'], input[name="quantity"]').change(function () { $.ajax({ url: 'index.php?route=product/product/getRecurringDescription', type: 'post', data: { 'product_id' : $('input[name=\'product_id\']').val(), 'quantity' : $('input[name=\'quantity\']').val(), 'recurring_id' : $('select[name=\'recurring_id\'] option:selected').val() }, dataType: 'json', beforeSend: function () { $('#recurring-description').html(''); }, success: function (json) { $('.alert, .text-danger').remove(); if (json['success']) { $('#recurring-description').html(json['success']); } }, error: function (error) { console.log(error.responseText); } }); }); $('#product input[type="date"]').on('blur', function(){ let formatDate = $(this).val() + 'T00:00:00-03:00'; let date = new Date(formatDate); date = date.toLocaleDateString('pt-BR'); $(this).next().val(date); }); $('#product input[type="datetime-local"]').on('blur', function(){ let formatDate = $(this).val().split('T')[0] + 'T00:00:00-03:00'; let date = new Date(formatDate); let time = $(this).val().split('T')[1]; date = date.toLocaleDateString('pt-BR'); $(this).next().val(`${date} ${time}`); }); function addCart(){ var package = ''; var redirect = '/'; if($(".sizes").hasClass('packageTrigger selected') || $('.option-type-select').find('.packageTrigger').length > 0 || $(".option_type_select > option").hasClass('packageTrigger') || $('#input-quantity').hasClass('packageTrigger')){ package = 'packageTrigger'; } let ga4_cart_items = []; let ga4_cart_total = 0; const data = $(` #product input[type=\'text\'], #product input[type=\'time\'], #product input[type=\'datetime-local\'], #product input[type=\'hidden\']:not(.buy-together-opt), #product #input-quantity, #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select:not(.buy-together-opt), #product textarea, #__csrf `); $.ajax({ url: 'index.php?route=checkout/cart/add&package=' + package + '&v='+new Date().getTime() + '&redirect=' + redirect, type: 'post', data: data, dataType: 'json', beforeSend: function () { if (smartHintEnabled == 0) { $('.button-cart').button('loading'); } }, async: false, success: function (json) { $('.alert, .text-danger').remove(); $('.form-group').removeClass('has-error'); $('#product .product-option-warning').remove(); let redirect = false; if(json.ga4){ ga4_cart_items.push(json.add_to_cart); ga4_cart_total += Number(json.item_price); } if (json['error']) { if (json['error']['option']) { for (i in json['error']['option']) { var element = $('#input-option' + i.replace('_', '-')); if (element.parent().hasClass('input-group')) { element.parent().after('
' + json['error']['option'][i] + '
'); } else { element.after('
' + json['error']['option'][i] + '
'); } } } if (json['error']['recurring']) { $('select[name=\'recurring_id\']').after('
' + json['error']['recurring'] + '
'); } if (json['error']['product']) { $('#button-cart').before('
' + json['error']['product'] + '
'); } if (json['error']['empty_option']) { $('#button-cart').before('