Custom Order

product title...

require([ 'VladimirPopov_WebForms/js/form', 'jquery', 'VladimirPopov_WebForms/js/sweetalert', 'jquery/jquery.cookie' ], function (VarienForm, jQuery, swal) { jQuery(document).ready(function () { var blockId = 'webform_0zqRvk'; var jblockId = '#' + blockId; var webform_0zqRvk = new VarienForm(blockId, 0); // Ajax submit jQuery('body').on('click', jblockId + ' .action.submit', function (e) { var form = webform_0zqRvk; if (typeof tinyMCE === 'object') tinyMCE.triggerSave(); if (!(form.validator && form.validator.validate())) { return; } var formData = new FormData(jQuery(jblockId)[0]); var self = this; e.preventDefault(); e.stopImmediatePropagation(); jQuery.ajax({ url: 'https://emballagetout.ca/en/webforms/form/submit/', data: formData, type: 'POST', cache: false, dataType: 'json', contentType: false, processData: false, beforeSend: function () { self.disable(); $(blockId + '_sending_data').show(); }, success: function (data, status, xhr) { if (data.success > 0) { if (data.script) { eval(data.script); return; } if (data.redirect_url) { $(blockId + '_progress_text').update('Redirecting'); // decode html entities window.location = jQuery('
').html(data.redirect_url).text(); return; } var successText = data.success_text; $(blockId + '_sending_data').hide(); $(blockId + '_submit_button').enable(); $(blockId).reset(); if (typeof DROPZONE !== "undefined") { if (typeof DROPZONE._0zqRvk !== "undefined") { for (var i = 0; i < DROPZONE._0zqRvk.length; i++) { DROPZONE._0zqRvk[i].reset(); } } } swal.fire({ title: 'Success!', html: successText, type: 'success' }); } else { $(blockId + '_submit_button').enable(); if ($(blockId + '_sending_data')) $(blockId + '_sending_data').hide(); if ($(blockId + '_submit_button')) $(blockId + '_submit_button').enable(); var errorTxt = ''; if (data.errors && typeof (data.errors) == "string") { errorTxt = data.errors.unescapeHTML(); } else { errorTxt = 'Unknown error(s) occured'; } swal.fire({ title: 'Error', html: errorTxt, type: 'error' }); if (data.script) { eval(data.script); } } }, error: function (xhr, status, errorThrown) { console.log('Error happens. Try again.'); console.log(errorThrown); } }); }); }); });