/** * 2019 by XTO.es * * XTO Product Gift * * NOTICE OF LICENSE * * This source file is subject to the General Public License (GPL 2.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/GPL-2.0 * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade the module to newer * versions in the future. * * @author XTO * @copyright 2018 Expertos Tiendas Online * @license http://opensource.org/licenses/GPL-2.0 General Public License (GPL 2.0) */ $(document).ready(function () { $(document).on('click', '#popup-gift .close', function () { $('#popup-gift').hide() $('#productgift').addClass('remember') var scrollProductGift = document.getElementById('productgift').offsetTop window.scrollTo({ top: scrollProductGift, behavior: 'smooth' }) }) $(document).on('click', '#button-gift', function () { $('#popup-gift').hide() $('#productgift').addClass('remember-alert') var scrollProductGift = document.getElementById('productgift').offsetTop window.scrollTo({ top: scrollProductGift, behavior: 'smooth' }) }) $(document).on("change", "#productgift", function (e) { $(this).removeClass('remember').removeClass('remember-alert') $.ajax({ url: module_path + 'ajax/app.php', data: { action: 'addProductGift', description: $("#productgift option:selected").val(), id_product: $("#productgift option:selected").data("product"), id_attribute: $("#productgift option:selected").data("attribute"), id_shop: id_shop, id_cart: id_cart, }, type: 'POST', dataType: 'json', success: function(data){ if(data.success) { console.log("OK!"); console.log(data); } else { console.log("ERROR!"); console.log(data); console.log(data.message); } }, error: function( jqXHR, textStatus, errorThrown ) { if (jqXHR.status === 0) { console.log('Not connect: Verify Network.'); } else if (jqXHR.status == 404) { console.log('Requested page not found [404]'); } else if (jqXHR.status == 500) { console.log('Internal Server Error [500].'); } else if (textStatus === 'parsererror') { console.log('Requested JSON parse failed.'); } else if (textStatus === 'timeout') { console.log('Time out error.'); } else if (textStatus === 'abort') { console.log('Ajax request aborted.'); } else { console.log('Uncaught Error: ' + jqXHR.responseText); } } }); }); });