401var paymentCurrency = wishlistBlock.getAttribute('data-userpayment-currency');402if (paymentCurrency) {403window.twishlist['currency'] = paymentCurrency;404}405406//////407// если валюта задана в настройках проекта:408var projectCurrency = wishlistBlock.getAttribute('data-project-currency');409if (projectCurrency) {410window.twishlist['currency'] = projectCurrency;411}412
// название валюты window.twishlist['currency_txt'] = window.twishlist['currency']; // расположение значка валюты projectCurrency = wishlistBlock.getAttribute('data-project-currency-side'); if (projectCurrency == 'r') { window.twishlist['currency_side'] = 'r'; } if (window.twishlist['currency_side'] == 'l') { window.twishlist['currency_txt_l'] = window.twishlist['currency_txt'] + ''; window.twishlist['currency_txt_r'] = ''; } else { window.twishlist['currency_txt_r'] = ' ' + window.twishlist['currency_txt']; window.twishlist['currency_txt_l'] = ''; } // десятичный разделитель projectCurrency = wishlistBlock.getAttribute('data-project-currency-sep'); if (projectCurrency == '.' || projectCurrency == ',') { window.twishlist['currency_sep'] = projectCurrency; } else if ( window.twishlist['currency'] == '$' || window.twishlist['currency'] == '€' || window.twishlist['currency'] == 'USD' || window.twishlist['currency'] == 'EUR' ) { window.twishlist['currency_sep'] = '.'; } else { window.twishlist['currency_sep'] = ','; } // десятичный формат projectCurrency = wishlistBlock.getAttribute('data-project-currency-dec'); if (projectCurrency == '00') { window.twishlist['currency_dec'] = projectCurrency; } else { window.twishlist['currency_dec'] = ''; } twishlist__updateTotalProductsObj();}/** * Сохраняет объект window.twishlist в localStorage, обновляет дату изменения */function twishlist__saveLocalObj() { // если max days == 0 - не сохраняем if (typeof window.twishlist_maxstoredays != 'undefined' && window.twishlist_maxstoredays == 0) { return; } if (typeof window.twishlist == 'object') { window.twishlist.updated = Math.floor(Date.now() / 1000); var dataJsonStr = JSON.stringify(window.twishlist); if (typeof localStorage === 'object') { try { localStorage.setItem('twishlist', dataJsonStr); } catch (e) { console.error('Your web browser does not support storing a Wishlist data locally.'); } } }}/** * Синхронизирует товары в объекте window.twishlist и localStorage */function twishlist__syncProductsObject__LStoObj() { if (typeof window.twishlist_maxstoredays != 'undefined' && window.twishlist_maxstoredays == 0) { return; } if (typeof localStorage === 'object') { try { var lsJsonStr = localStorage.getItem('twishlist'); var lsJsonObj = JSON.parse(lsJsonStr); if (typeof lsJsonObj['products'] == 'object') { // удаляет из window.twishlist пустые или удаленные товары var actualProductsObj = []; var oldCountProducts = lsJsonObj['products'].length; lsJsonObj['products'].forEach(function (product) { if (!twishlist__isEmptyObject(product) && product.deleted !== 'yes' && product.quantity > 0) { actualProductsObj.push(product); } }); window.twishlist['products'] = actualProductsObj; var actualCountProducts = window.twishlist['products'].length;