* @returns {Element} элемент товара
215function tmst__purchased__createProductEl(product) { 216 var { purchased, sku, title } = product; 219 <article class="tmst-purchased__list-item" role="listitem" arialabel="${title} tabIndex="0"> 220 <div class="tmst-purchased__product"> 221 <div class="tmst-purchased__product-details"> 222 <div class="tmst-purchased__product-details__col-1"> 223 <div class="tmst-purchased__product-details__image"> 224 ${tmst__purchased__createProductImageHtml(product)} 226 <div class="tmst-purchased__product-details__description"> 227 ${tmst__purchased__createProductTitleHtml(product)} 228 <div class="tmst-purchased__details__product-sku">${sku}</div> 229 ${tmst__purchased__createProductOptionsHtml(product)} 232 <div class="tmst-purchased__product-details__col-2"> 233 <div class="tmst-purchased__product-details__info"> 234 <div class="tmst-purchased__product-details__date"> 235 ${tmst__formatDate(purchased, 'date')} 237 <div class="tmst-purchased__product-details__price"> 238 ${tmst__purchased__createProductPriceHtml(product)} 241 <div class="tmst-purchased__product-details__action"> 242 ${tmst__purchased__createProductActionHtml(product)} 249 var productEl = tmst__createElementFromString(elementHtml); 251 var addToCartBtn = productEl.querySelector('.js-add-to-cart-btn'); 253 addToCartBtn.addEventListener('click', () => { 254 if (!tmst__checkCartEl()) return; 256 tmst__addProductToCart(product); 264 * Получает разметку для заголовка 265 * @param {PurchasedProduct} product 268function tmst__purchased__createProductTitleHtml(product) { 270 if (product.available) { 271 wrapper = document.createElement('a'); 272 wrapper.href = product.url; 274 wrapper = document.createElement('div'); 277 wrapper.className = 'tmst-purchased__details__product-title'; 278 wrapper.insertAdjacentHTML('afterbegin', product.title); 280 return wrapper.outerHTML; 284 * Получает разметку для картинки товара 285 * @param {PurchasedProduct} product 288function tmst__purchased__createProductImageHtml(product) { 290 if (product.available) { 291 wrapper = document.createElement('a'); 292 wrapper.href = product.url; 294 wrapper = document.createElement('div'); 297 wrapper.insertAdjacentHTML( 300 ? tmst__purchased__createWithImageHtml(product)