I have a problem in PrestaShop 1.7.7.8 and I use supercheckout module.
If I override classes/Validate.php file to the override folder, and edit some regex epressions I get the error: "Technical Error-Request Failed". (Picture 1). If I revert the epression back the problem goes away. And the other point is this error seems just for guest users. If I log in and go to the supercheckout page, I won't see any error and it will work fine. So I want to edit Regex expressions.
I tried to find the solution. I found that the error is defined inside that file: \modules\supercheckout\views\templates\front\supercheckout.tpl
I got it in the comment line. (Picture 2). And I got the error in the third picture (Picture 3).
The id_address_delivery variable is empty. If I set a value 1 to this variable, it works fine the first time, but if I go to the page to purchase products again, I encounter the error in the fourth picture (Picture 4). Finally that is my Regex expressions (**Picture 5**😞
So the problem is in the Ajax request (modules/supercheckout/views/js/front/supercheckout.js), but I cannot find it:
var shipping_error_found_on_load = false;
function loadCarriers() {
var requestParam = getCounrtryAndIdDelivery();
var id_country = requestParam[0];
var id_state = 0;
if (checkStateVisibility(id_country, 'select[name="shipping_address[id_state]"]')) {
id_state = $('select[name="shipping_address[id_state]"]').val();
}
var postcode = $('input[name="shipping_address[postcode]"]').val();
var id_address_delivery = requestParam[1];
var vat_code = '';
if ($('input[name="shipping_address[vat_number]"]').val() != 'undefined' &&
$('input[name="shipping_address[vat_number]"]').val() != '' &&
$('input[name="shipping_address[vat_number]"]').val() != null) {
vat_code = $('input[name="shipping_address[vat_number]"]').val();
}
shipping_error_found_on_load = false;
$.ajax({
type: 'POST',
headers: {
"cache-control": "no-cache"
},
url: getURLwithTime($('#module_url').val()),
async: true,
cache: false,
dataType: "json",
data: 'ajax=true' + '&id_country=' + id_country + '&id_state=' + id_state + '&postcode=' + postcode + '&vat_number=' + vat_code + '&id_address_delivery=' + id_address_delivery + '&method=loadCarriers&token=' + prestashop.static_token,
beforeSend: function() {
alert(8541);
$('.kb_velsof_sc_overlay').show();$('.pay-loader').show();
$('#shippingMethodLoader').show();
$('#shipping_method_update_warning .permanent-warning').remove();
alert(8888);
},
complete: function() {
alert(77777);
$('.kb_velsof_sc_overlay').hide();$('.pay-loader').hide();
$('#shippingMethodLoader').hide();
},
success: function(jsonData) {
if (jsonData['hasError']) {
$('#shipping-method').html('');
$('#shipping_method_update_warning').html('<div class="permanent-warning">' + jsonData['shipping_error'][0] + '</div>');
} else {
$('#shipping-method').html(jsonData['html']);
}
$('.delivery_option_radio:checked').closest('li').addClass('alert-info');
set_column_inside_height();
//loadCart();
/* Start Code Added By Priyanshu on 11-Feb-2021 for the packetery ( Zasilkovna ) compatibility */
if (typeof onShippingLoadedCallback !== 'undefined') {
onShippingLoadedCallback();
}
/* End Code Added By Priyanshu on 11-Feb-2021 for the packetery ( Zasilkovna ) compatibility */
updateCarrierOnDeliveryChange()
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
var errors = sprintf(ajaxRequestFailedMsg, XMLHttpRequest, textStatus);
$('#shipping_method_update_warning').html('<div class="permanent-warning">' + errors + '</div>');
$('.kb_velsof_sc_overlay').hide();$('.pay-loader').hide();
}
});
}
function getCounrtryAndIdDelivery() {
var id_country = 0;
var id_address_delivery = '';
if ($('input[name="shipping_address_value"]').length) {
if ($('input[name="shipping_address_value"]:checked').val() == 1) {
id_country = $('select[name="shipping_address[id_country]"] option:selected').val();
} else if ($('input[name="shipping_address_value"]:checked').val() == 0) {
id_address_delivery = $('select[name="shipping_address_id"] option:selected').val();
}
} else {
id_country = $('select[name="shipping_address[id_country]"] option:selected').val();
}
var arr = [];
arr.push(id_country);
arr.push(id_address_delivery);
return arr;
}``
}`
I have a problem in PrestaShop 1.7.7.8 and I use supercheckout module.
If I override classes/Validate.php file to the override folder, and edit some regex epressions I get the error: "Technical Error-Request Failed". (Picture 1). If I revert the epression back the problem goes away. And the other point is this error seems just for guest users. If I log in and go to the supercheckout page, I won't see any error and it will work fine. So I want to edit Regex expressions.
I tried to find the solution. I found that the error is defined inside that file: \modules\supercheckout\views\templates\front\supercheckout.tpl
I got it in the comment line. (Picture 2). And I got the error in the third picture (Picture 3).
The id_address_delivery variable is empty. If I set a value 1 to this variable, it works fine the first time, but if I go to the page to purchase products again, I encounter the error in the fourth picture (Picture 4). Finally that is my Regex expressions (**Picture 5**😞
So the problem is in the Ajax request (modules/supercheckout/views/js/front/supercheckout.js), but I cannot find it:
}`