Skip to content

Uncaught SyntaxError: ” string literal contains an unescaped line break on product page for some products

Magento 2.4.6

Getting this error in this piece of code … I have been looking at it for a while now but can not find the problem … can you help me out?

<ul
class="prices-tier items">
<% var basePriceTemplate = ' <span
class="price-wrapper price-excluding-tax"'
+ 'data-label="Exkl. Steuern">'
+ '<span
class="price">&nbsp;%1</span>'
+ '</span>'
%><% _.each(tierPrices, function(item, key) { %>
<% var itemBasePrice = item.hasOwnProperty('basePrice')
? basePriceTemplate.replace('%1', priceUtils.formatPrice(item['basePrice'], currencyFormat))
: ''
%><% var priceStr = '<span
class="price-container price-tier_price">'
+ '<span
data-price-amount="' + priceUtils.formatPrice(item.price, currencyFormat) + '"'
+ ' data-price-type=""' + ' class="price-wrapper price-including-tax">'
+ '<span
class="price">' + priceUtils.formatPrice(item.price, currencyFormat) + '</span>'
+ '</span>' + itemBasePrice + '</span>';
%><li
class="item">
<%= 'Kaufen Sie %1 für jeweils %2 und'
.replace('%1', item.qty)
.replace('%2', priceStr)
%>
<strong
class="benefit">
sparen Sie<span
class="percent tier-<%= key %>">&nbsp;<%= item.percentage %></span>%
</strong></li>
<% }); %></ul>

Thats how it gets printed to the console, I left it this way without formatting.

This code is contained in this.options.tierPriceTemplate in the following code in configurable.js.

$(this.options.tierPriceBlockSelector).html(
       mageTemplate(this.options.tierPriceTemplate, {
                            'tierPrices': tierPrices,
                            '$t': $t,
                            'currencyFormat':this.options.spConfig.currencyFormat,
                            'priceUtils': priceUtils
                        })
                    ).show();

Does not happen for all prtoducts, but for some.

Thanks for any idea!