Fehler beim Akzeptieren einer Freundschaftsanfrage

var saleDetails = { saleEnd: '', cartSummary: { item_count: 0, items_subtotal_price: 0, original_total_price: 0, requires_shipping: false, total_discount: 0, total_price: 0, }, cartMessage:"[#%] discount applied for our Fall Sale", cartDiscount_code: '', fixedDiscount: '', locale: 'fr', offer: { you_save: "Vous économisez", buy: "Achetez-en", off: "de rabais"}, items: [ { sku : "426", id: 47342076100953, price: 18999, saleCopy: "", saleCopyBi: "", copyColor: "", blockBg: "", bannerBlockBgColor: false, spendAmount: "", disclaimer: "", hideSticker: false, sticker: null, discountType: "123plus", valueOff: "percent-off", discountValue: "0.15, 0.15, 0.15", extra_dollar: "0, 10, 20", stickerBi: null, addDiscountCopy: "", addDiscountCopyBi: "" }, { sku : "428", id: 47342215233881, price: 19999, saleCopy: "", saleCopyBi: "", copyColor: "", blockBg: "", bannerBlockBgColor: false, spendAmount: "", disclaimer: "", hideSticker: false, sticker: null, discountType: "123plus", valueOff: "percent-off", discountValue: "0.15, 0.15, 0.15", extra_dollar: "0, 10, 20", stickerBi: null, addDiscountCopy: "", addDiscountCopyBi: "" },{ sku : "419", id: 47342215266649, price: 19999, saleCopy: "", saleCopyBi: "", copyColor: "", blockBg: "", bannerBlockBgColor: false, spendAmount: "", disclaimer: "", hideSticker: false, sticker: null, discountType: "123plus", valueOff: "percent-off", discountValue: "0.15, 0.15, 0.15", extra_dollar: "0, 10, 20", stickerBi: null, addDiscountCopy: "", addDiscountCopyBi: "" },{ sku : "427", id: 47342215299417, price: 19999, saleCopy: "", saleCopyBi: "", copyColor: "", blockBg: "", bannerBlockBgColor: false, spendAmount: "", disclaimer: "", hideSticker: false, sticker: null, discountType: "123plus", valueOff: "percent-off", discountValue: "0.15, 0.15, 0.15", extra_dollar: "0, 10, 20", stickerBi: null, addDiscountCopy: "", addDiscountCopyBi: "" }, { sku : "705", id: 54781599285623, price: 34999, saleCopy: "", saleCopyBi: "", copyColor: "", blockBg: "", bannerBlockBgColor: false, spendAmount: "", disclaimer: "", hideSticker: false, sticker: null, discountType: "123plus", valueOff: "percent-off", discountValue: "0.15, 0.15, 0.15", extra_dollar: "0, 15, 30", stickerBi: null, addDiscountCopy: "", addDiscountCopyBi: "" },] }; window.saleDetails = saleDetails; var saleFunctions = { getPrice: function (line, qtt) { var price = line.price; var quantity = qtt || 1 var valueOff = line.valueOff var values = String(line.discountValue).split(','); let extra_dollar = (String(line.extra_dollar).includes(',')) ? line.extra_dollar.split(',').map(Number) : Number(line.extra_dollar || 0); let finalExtraDollar = 0 var totalPrice = 0 var unitPrice = 0 var difference = 0 switch (line.discountType) { case 'none': unitPrice = price finalPrice = price * quantity break; case 'fixed': var discount_value = Number(values[0]); unitPrice = (valueOff === 'percent-off') ? price * (1 - discount_value) : price - (discount_value * 100); unitPrice = (Math.floor(unitPrice/100)+ 0.99)*100 - extra_dollar finalPrice = unitPrice * quantity; difference = price - unitPrice break; case '3plus': break; case '123plus': var discount_value; if(quantity == 1) { discount_value = Number(values[0]); finalExtraDollar = ( typeof extra_dollar === 'object') ? extra_dollar[0] : extra_dollar } else if (quantity == 2) { discount_value = Number(values[1]); finalExtraDollar = ( typeof extra_dollar === 'object') ? (extra_dollar[1]/2) : extra_dollar/2 } else { discount_value = Number(values[2]); finalExtraDollar = ( typeof extra_dollar === 'object') ? (extra_dollar[2]/3) : extra_dollar/3 } unitPrice = (valueOff === 'percent-off') ? price * (1 - discount_value) : price - ((discount_value*100) / quantity); unitPrice = (valueOff === 'percent-off') ? (Math.floor(unitPrice/100)+ 0.99)*100 - (finalExtraDollar * 100) : unitPrice - (finalExtraDollar * 100) finalPrice = unitPrice * quantity; difference = price - unitPrice break; case '1235plus': break; case '12plus': var discount_value; if(quantity == 1) { discount_value = Number(values[0]); } else { discount_value = Number(values[1]); } unitPrice = (valueOff === 'percent-off') ? price * (1 - discount_value) : price - (discount_value * 100); unitPrice = (Math.floor(unitPrice/100)+ 0.99)*100 finalPrice = unitPrice * quantity; difference = price - unitPrice break; case 'spend': var cartTriggers = String(line.spendAmount).split(','); var lastPositiveIndex = -1; cartTriggers.forEach((trigger, index) => { var triggerValue = Number(trigger) var cartValue = (Number(window.saleDetails.cartSummary.original_total_price || 0) + Number(price))/ 100 if(cartValue > triggerValue) { lastPositiveIndex = index } }); discount_value = lastPositiveIndex > -1 ? Number(values[lastPositiveIndex] || 0) : 0; unitPrice = (valueOff === 'percent-off') ? price * (1 - discount_value) : price - (discount_value * 100); finalPrice = unitPrice * quantity; difference = price - unitPrice break; case 'bogox': break; case 'bogo': break; default: console.log(`Sorry, we are out of`); } return { finalPrice: finalPrice, unitPrice: unitPrice, difference: difference, extra_dollar: finalExtraDollar } }, updateCartSummary: function(cart) { window.saleDetails.cartSummary = { item_count: cart.item_count, items_subtotal_price: cart.items_subtotal_price, original_total_price: cart.original_total_price, requires_shipping: cart.requires_shipping, total_discount: cart.total_discount, total_price: cart.total_price, } } } window.saleFunctions = saleFunctions;