add empik module

This commit is contained in:
2025-05-30 09:08:26 +02:00
parent 87a41f4cfc
commit 56aa2cdc2d
1466 changed files with 138249 additions and 146 deletions

View File

@@ -0,0 +1,126 @@
$(function () {
const empikProductExportButtonSelector = '.js-empik-products-export';
const empikOfferExportButtonSelector = '.js-empik-offers-export';
const empikPriceInputSelector = '.js-empik-price-input';
$(document).on('click', empikProductExportButtonSelector, function (e) {
e.preventDefault();
$(this).attr('disabled', 'disabled');
let page = 0;
ajaxRequest();
function ajaxRequest() {
const formData = new FormData();
formData.append('action', 'exportProducts');
formData.append('page', page);
$.ajax({
method: 'post',
url: empikAjaxUrl,
data: formData,
processData: false,
contentType: false,
dataType: 'json',
success: function (response) {
if (response.success) {
if (response.continue) {
page++;
ajaxRequest();
} else {
window.location = response.redirect;
$(this).removeAttr('disabled');
}
} else {
alert(response.errors[0]);
}
},
});
}
});
$(document).on('click', empikOfferExportButtonSelector, function (e) {
e.preventDefault();
$(this).attr('disabled', 'disabled');
let page = 0;
ajaxRequest();
function ajaxRequest() {
const formData = new FormData();
formData.append('action', 'exportOffers');
formData.append('page', page);
$.ajax({
method: 'post',
url: empikAjaxUrl,
data: formData,
processData: false,
contentType: false,
dataType: 'json',
success: function (response) {
if (response.success) {
if (response.continue) {
page++;
ajaxRequest();
} else {
window.location = response.redirect;
$(this).removeAttr('disabled');
}
} else {
alert(response.errors[0]);
}
},
});
}
});
$(document).on('change', empikPriceInputSelector, function (e) {
const value = $(this).val();
// replace , with .
let formattedValue = value.replace(',', '.');
// remove all non-numeric characters
formattedValue = formattedValue.replace(/[^0-9\.]/g, '');
formattedValue = parseFloat(formattedValue);
// check is value is a number
if (isNaN(formattedValue)) {
formattedValue = 0.00;
}
formattedValue = formattedValue.toFixed(2);
$(this).val(formattedValue);
});
$(document).on('change', empikPriceInputSelector, function (e) {
e.preventDefault();
const formData = new FormData();
formData.append('action', $(this).data('action'));
formData.append('id_product', $(this).data('product-id'));
formData.append('id_product_attribute', $(this).data('product-attribute-id'));
formData.append('price', $(this).val());
$.ajax({
method: 'post',
url: empikAjaxUrl,
data: formData,
processData: false,
contentType: false,
dataType: 'json',
success: (response) => {
if (response.success && typeof response.message !== 'undefined') {
showSuccessMessage(response.message);
}
},
});
});
});

View File

@@ -0,0 +1,11 @@
<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;