* 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-single .product-price-old').html('De ' + jsonPO.price + prefix); $('.product-single .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-single .product-price-discount .discount_simulator').length){ $('.product-single .product-price-discount').html(' ou '+ jsonPO.special_discount +'à vista ' + text_special_porcent + text_discount + cash_discount_alert +''+ cash_discount); } else{ $('.product-single .product-price-discount').html(' ou '+ jsonPO.special_discount +'à vista' + text_discount + cash_discount_alert + cash_discount); } } }else{ if(!square) { $('.product-single .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-single .product-price-discount .discount_simulator').length){ $('.product-single .product-price-discount').html(' ou '+jsonPO.price_discount+' à vista ' + text_special_porcent + text_discount + cash_discount_alert +''+ cash_discount); } else{ $('.product-single .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-single .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'); }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log(XMLHttpRequest.responseText); } }); } $('#input-square').change(function() { priceOptionClick('square_package'); }); $('[data-toggle="popover"]').click(function(){ priceOptionClick(); }); $('.grid-remove-selected').click(function () { $(this).parent().removeClass('selected'); $(this).parent().removeClass('grid_selected'); return false; }); /* Adição e Subtração */ $('#input-quantity').change(function() { priceOptionClick(); }); }); $('.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; $('#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 = ''; var params = { "postcode": $('input[name=\'postcode\']').val(), "product_id": '42', "weight": '0.2790', "width": width, "height": height, "days_stock": '0', "price": '109.99', "price_without_currency": '109.99', "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 || total_stock_quantity < 1){ $('#modal-shipping').empty(); $('#button-quote_product').button('loading'); $('#modal-shipping').html('
Para poder realizar o calculo do frete escolha seu numero e a quantidade desejada. '); $('#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 () { $('#button-quote_product').button('loading'); }, complete: function () { $('#button-quote_product').button('reset'); }, 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(); $('.postcode-inputs').append('
x
' + json['error']['warning'] + '
'); } if (json['error']['postcode']) { $('.postcode-inputs').append('
' + json['error']['postcode'] + '
'); } } 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['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 == '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 { 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]['info']){ html += ''+json['shipping_method'][j]['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'] + ''; } } } } } 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 += '