/home/sharedstore/public_html/prestashop.sharedstore.ma/modules/productquotation/views/js
NameSizeModeActions
ckeditor_config.js6840644editdlrm
front.js90330644editdlrm
index.php13720644editdlrm
popupscript.js25570644editdlrm
productquote-17.js83410644editdlrm
productquote.js68410644editdlrm
Edit: /home/sharedstore/public_html/prestashop.sharedstore.ma/modules/productquotation/views/js/front.js (9033B)
/** * Copyright ETS Software Technology Co., Ltd * * NOTICE OF LICENSE * * This file is not open source! Each license that you purchased is only available for 1 website only. * If you want to use this file on more websites (or projects), you need to purchase additional licenses. * You are not allowed to redistribute, resell, lease, license, sub-license or offer our resources to any third party. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. * * @author ETS Software Technology Co., Ltd * @copyright ETS Software Technology Co., Ltd * @license Valid for 1 website (or project) for each purchase of license */ var PQUOTE_GOOGLE_V3_CAPTCHA_SITE_KEY = PQUOTE_GOOGLE_V3_CAPTCHA_SITE_KEY || false; var PQUOTE_GOOGLE_V3_POSITION = PQUOTE_GOOGLE_V3_POSITION || 'bottomright'; var PQUOTE_GOOGLE_CAPTCHA_THEME = 'light'; var func_pquote_form = { loadReCaptchaV3: function (form) { if ($('form:not(.g-loaded)').length <= 0 || !PQUOTE_GOOGLE_V3_CAPTCHA_SITE_KEY) { return false; } var g_captcha = form.find('[id*=g-recaptcha-response-]'); if (g_captcha.length > 0 && $('body').attr('id')) { grecaptcha.ready(function () { var renderClientId = grecaptcha.render(g_captcha[0].id, { 'sitekey': PQUOTE_GOOGLE_V3_CAPTCHA_SITE_KEY, 'badge': PQUOTE_GOOGLE_V3_POSITION, 'size': 'invisible', 'theme' : PQUOTE_GOOGLE_CAPTCHA_THEME, }); grecaptcha.execute(renderClientId, {action: $('body').attr('id').replace(/(?=[^A-Za-z\_])([^A-Za-z\_])/g, '_')}).then(function (token) { if (token) { if (g_captcha.find('input[name=g-recaptcha-response]').length > 0) { g_captcha.find('input[name=g-recaptcha-response]').val(token); } else { g_captcha.append(''); } form.addClass('g-loaded'); func_pquote_form.loadReCaptchaV3($('form:not(.g-loaded)')); } }); }); } } } $(document).ready(function () { //updatecart prestashop.on('updateCart', function(event) { setTimeout(function() { var ____img_src = $('.product-cover img').attr('src'); var ____product_name = $('.product-container h1:first-child').text(); $('#blockcart-modal img.product-image').attr('src', ____img_src); $('#blockcart-modal .product-name').text(____product_name); }, 1500); }); //adding quotation product to cart $(document).on('click', '#productquotation_btn', function () { var div_id = $('#fmm_quote_from'); if (div_id.length) { submitForm(div_id); } else { console.error('Form not found!'); } }); if (PQUOTE_GOOGLE_V3_CAPTCHA_SITE_KEY) { func_pquote_form.loadReCaptchaV3($('form:not(.g-loaded)')); } if($('#customer-form #field-captcha').length) { $('#customer-form #field-captcha').parents('.form-group.row').hide(); if($('#field-captcha').next('.help-block').length) { $('.captcha_register .g-recaptcha').after($('#field-captcha').next('.help-block').clone()); } } //resubmitting quotation request if time is over $(document).on('click', '.resubmit-quote', function () { var quoteId = $(this).data('quote-id'); if (quoteId) { $.ajax({ url: resubmit_quote_url, type: 'POST', data: { ajax: '1', action: 'resubmitQuote', id_quote: quoteId }, dataType: "json", success: function (response) { $('#messageContainerTable').hide().removeClass('alert-success alert-danger').empty(); if (response.success) { $('#messageContainerTable').addClass('alert-success').text('Quote is re-submitted!'); } else { $('#messageContainerTable').addClass('alert-danger').text(response.error || 'An error occurred while resubmitting the quotation.'); console.log(response.error || 'An error occurred while resubmitting the quotation.'); } $('#messageContainerTable').show(); }, error: function (xhr, status, error) { $('#messageContainerTable').hide().removeClass('alert-success alert-danger').empty(); $('#messageContainerTable').addClass('alert-danger').text('AJAX error:', status, error); $('#messageContainerTable').show(); } }); } }); }); function submitForm(div_id) { var productsData = []; div_id.find('.fmm_content_holder li').each(function () { var productData = { product_id: $(this).find('input[name="pq_id_product"]').val(), id_product_attribute: $(this).find('input[name="pq_id_product_attribute"]').val(), qty: $(this).find('.fmm_quote_row_qty').val(), combination: $(this).find('input[name="pq_combination"]').val() }; productsData.push(productData); }); $.ajax({ url: product_add_to_cart, method: 'POST', data: { ajax: '1', action: 'addProductToCart', form_datas: JSON.stringify(productsData), }, dataType: "json", success: function (data) { $('#messageContainer').hide().removeClass('alert-success alert-danger').empty(); if (data.hasError) { $('#messageContainer').addClass('alert-danger').text(data.error_message || 'An error occurred'); var content = data.id_field; $('#' + data.id_field).text(data[content]); } else { $('#messageContainer').addClass('alert-success').text('Product added to cart successfully!'); data.products.forEach(product => { if (typeof product.id_customization !== 'undefined') { $('#product_customization_id').val(product.id_customization); } }); setTimeout(function () { window.location.reload(); }, 2000); } $('#messageContainer').show(); }, error: function (xhr, status, error) { $('#messageContainer').hide().removeClass('alert-success alert-danger').empty(); $('#messageContainer').addClass('alert-danger').text('An error occurred while adding to cart.'); $('#messageContainer').show(); } }); } document.addEventListener('DOMContentLoaded', () => { const qtyInputs = document.querySelectorAll('.fmm_quote_row_qty'); qtyInputs.forEach(input => { input.addEventListener('input', function () { const originalPrice = parseFloat( this.closest('li').querySelector('input[name="original-price"]').value.replace(/[^\d.-]/g, '') ); const productId = parseFloat( this.closest('li').querySelector('input[name="pq_id_product"]').value.replace(/[^\d.-]/g, '') ); const productAttributeId = parseFloat( this.closest('li').querySelector('input[name="pq_id_product_attribute"]').value.replace(/[^\d.-]/g, '') ); const qty = parseInt(this.value) || 0; const totalPrice = originalPrice * qty; const priceDisplay = this.closest('li').querySelector('.total-price'); priceDisplay.textContent = `(${totalPrice.toFixed(2)})`; $.ajax({ type: "POST", url: product_add_to_cart, data: { action: 'updatePrice&quantity', product_id: productId, product_attribute_id: productAttributeId, price: totalPrice, quantity: qty, }, success: function(response) { setTimeout(() => { location.reload(); }, 2000); }, error: function(error) { console.log('Error updating price'); } }); }); }); });