* 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 = ''; let height = ''; 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 = '20'; weight = '0.0200'; price_without_currency = '20.00'; } var params = { "postcode": $('input[name=\'postcode\']').val(), "product_id": '2234', "weight": weight, "width": width, "height": height, "days_stock": '0', "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 += '