3001};3002xhr.ontimeout = onError;3003xhr.onerror = onError;3004}30053006var that = this;3007if (!that.endpointDelivery) {3008that.endpointDelivery = '.tildacdn.com';3009}3010xhr.open('POST', 'https://delivery' + that.endpointDelivery + '/cart-api/');3011xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8');3012
xhr.timeout = 30000; xhr.send(dataObj); }, /** * Getting a pickup list * * @param {object} params A set of parameters used to getting the pickup list * @param {string} params.projectId project id * @param {string} params.postalCode postal code * @param {string} params.deliveryId delivery id * @param {string} [params.pattern] pattern * @param {Function} params.onDone callback function on success * @param {Function} [params.onFail] callback function on fail */ getPickupList: function (params) { tcart__blockSubmitButton(); this.updateTotal(); var itemsCount = window.tcart.total || 0; if (itemsCount === undefined || itemsCount < 1) { params.onDone({ error: new Error( window.t_delivery__browserLang === 'RU' ? 'добавьте в корзину хотя бы один товар' : 'add at least one product' ), }); return; } var cartAmount = window.tcart.prodamount || 0; if (window.tcart.prodamount_withdiscount || window.tcart.prodamount_withdiscount === 0) { cartAmount = window.tcart.prodamount_withdiscount; } else if ( window.t_cart__discounts && window.t_cart__discounts.length > 0 && typeof window.tcart.prodamount_withdyndiscount !== 'undefined' ) { cartAmount = window.tcart.prodamount_withdyndiscount; } var products = this.removeEmptyOrDeletedProducts(); var dataObj = { action: 'pickup-list', projectId: params.projectId, postalCode: params.postalCode || 0, deliveryId: params.deliveryId, pattern: params.pattern, itemsCount: itemsCount, cartAmount: cartAmount, geoData: this.deliveryState.geoData || {}, products: products, paytypes: this.getPayTypes(), }; var allRecords = document.getElementById('allrecords'); var tildaProjectLang = allRecords.getAttribute('data-tilda-project-lang'); if (tildaProjectLang) { dataObj.lang = tildaProjectLang; } var tildaRootZone = allRecords.getAttribute('data-tilda-root-zone'); if (tildaRootZone) { dataObj.rz = tildaRootZone; } dataObj = JSON.stringify(dataObj); var xhr = new XMLHttpRequest(); xhr.onload = function () { if (xhr.readyState === xhr.DONE && xhr.status === 200) { params.onDone(JSON.parse(xhr.responseText)); } tcart__updateDelivery(); }; if (typeof params.onFail === 'function') { const onError = function (error) { xhr.isTimeout = error.type === 'timeout'; params.onFail(xhr); }; xhr.ontimeout = onError; xhr.onerror = onError; }