if (!product.image) return '';
314 var productTitle = product.title; 317 class="tmst-purchased__list__product-image" 318 src="${product.image}" 319 title="${productTitle}" 324 * Получает разметку для опций 325 * @param {PurchasedProduct} product 328function tmst__purchased__createProductOptionsHtml(product) { 329 if (!product.options) return ''; 331 var options = product.options.filter(option => option.variant); 332 if (options.length === 0) return ''; 334 var getOptionHtml = option => ` 335 <div class="tmst-purchased__details__product-option"> 336 <span class="tmst-purchased__details__product-option-name">${option.option}:</span> 337 <span class="tmst-purchased__details__product-option-value">${option.variant}</span> 341 return `<div class="tmst-purchased__details__product-options"> 342 ${options.map(getOptionHtml).join('')} 347 * Создаёт HTML-код для цены 349 * @param {PurchasedProduct} product 352function tmst__purchased__createProductPriceHtml(product) { 353 if (!product.purchasable) return ''; 355 return tmst__formatPrice(product.price, window.project_currency); 359 * Создаёт HTML-код для панели с действиями 361 * @param {PurchasedProduct} product 364function tmst__purchased__createProductActionHtml(product) { 365 var { uid, purchasable, available, url, parent_uid, available_quantity } = product; 366 // У блочных товаров productid всегда равен 0 367 var isRealProduct = uid > 0; 368 // У блочного товара available_quantity не существует 369 // В каталожном товаре если available_quantity === '', то это бесконечность 370 var hasQuantity = available_quantity === undefined || available_quantity === '' || parseInt(available_quantity) > 0; 371 var hasOtherEdition = !!parent_uid; 374 if (available && purchasable && (hasQuantity || !isRealProduct)) { 375 buttonHtml = '<button class="tmst-button tmst-button_primary js-add-to-cart-btn">{{add_to_cart}}</button>'; 376 } else if (available) { 377 buttonHtml = `<a class="tmst-button tmst-button_secondary" href="${url}">{{go_to_product}}</a>`; 379 buttonHtml = '<a class="tmst-button tmst-button_secondary" href="/">{{go_to_catalog}}</a>'; 382 var detailsHtml = ''; 383 if (available && purchasable && (hasQuantity || !isRealProduct)) { 384 detailsHtml = `<a href="${url}" class="tmst-button tmst-purchased__go-to-catalog-btn tmst-button_secondary" data-field="tlk-link">{{go_to_product}}</a>`; 385 } else if (available && purchasable && !hasQuantity && hasOtherEdition) { 386 detailsHtml = '{{check_another_variant}}'; 387 } else if (available && purchasable && !hasQuantity && isRealProduct) { 388 detailsHtml = '{{out_of_stock}}'; 389 } else if (available && !purchasable && hasOtherEdition && isRealProduct) { 390 detailsHtml = '{{variant_changed}}'; 391 } else if (available && !purchasable) { 392 detailsHtml = '{{product_changed}}'; 393 } else if (!available) { 394 detailsHtml = '{{check_another_product}}'; 398 detailsHtml = `<div class="tmst-purchased__product-cta-details">${detailsHtml}</div>`;