0

我在 PrestaShop 1.7.7.8 中遇到问题,我使用 supercheckout 模块。

如果我将 classes/Validate.php 文件覆盖到覆盖文件夹,并编辑一些正则表达式 epressions,我会收到错误:“ Technical Error-Request Failed ”。(图1)。如果我恢复 epression,问题就会消失。另一点是这个错误似乎只针对来宾用户。如果我登录并转到 supercheckout 页面,我不会看到任何错误,它会正常工作。所以我想编辑正则表达式。

我试图找到解决方案。我发现错误是在该文件中定义的:\modules\supercheckout\views\templates\front\supercheckout.tpl

我是在评论区看到的。(图2)。我在第三张图片中得到了错误(图3)。

id_address_delivery变量为空。如果我给这个变量设置一个值1,它第一次可以正常工作,但是如果我再次进入页面购买产品,我会遇到第四张图片中的错误(图4)。最后就是我的正则表达式(**图 5 **

所以问题出在 Ajax 请求中(modules/supercheckout/views/js/front/supercheckout.js),但我找不到它:

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;
    }

[the page contains the error - picture 1][1]
[comment line the error variable - picture 2][2]
[the second error - picture 3][3]
[the third error - picture 4][4]
[my regex expressions - picture 5][5]
4

0 回答 0