Skip to main content

ShopHQ | Boutique Shopping

ON AIR NOW
This Hour:
LAST 12 ITEMS AIRED
`; var templateRecommendations = ``; if (recommendations) { var cookie = typeof $.cookie !== "undefined" ? $.cookie("RViewSHOP1") : false; if (typeof cookie !== "undefined" && cookie.length > 0) { var offerCode = decodeURIComponent(cookie).split("|").shift().replace("#", ""); console.log("Checking recommendations for Offer Code: " + offerCode); getRecommendations(offerCode).then(function (data) { var items = pickRecommendationSet(data, 4); if (items) { var preparedItems = prepareRecommendationItems(items); initBoutiqueCarousel(recommendations, templateRecommendations, preparedItems); } else { console.log("No recommendations found"); initBoutiqueCarousel(boutique, templateBoutique); } }); } else { console.log("No cookie found"); initBoutiqueCarousel(boutique, templateBoutique); } } else { initBoutiqueCarousel(boutique, templateBoutique); } function initBoutiqueCarousel(selector, template, items) { var el; if (typeof selector === "string") { el = document.querySelector(selector); if (!el) return; } else { el = selector; } var boutique = el.querySelector(".boutique-carousel__wrapper"); if (!boutique) return; el.style.display = "block"; var title = boutique.dataset.title.replace(/ /g, ""); if (typeof items === "undefined") { var url = boutique.dataset.boutiqueurl ? boutique.dataset.boutiqueurl : null; if (!url) return; if ("IntersectionObserver" in window) { var observer = new IntersectionObserver(function (entries) { entries.forEach(function (entry) { if (entry.intersectionRatio > 0) { getItems(); observer.unobserve(entry.target); } }); }, { rootMargin: "500px" }); observer.observe(boutique); } else { getItems(); } } else { $(boutique).html(renderList(template, items)); initCarousel(boutique); } function getItems() { var items = load(id) || null; if (items) { var preparedItems = prepareBoutiqueItems(items); $(boutique).html(renderList(template, preparedItems)); console.log('storage items: ', items) initCarousel(boutique, items); } else { let results = index.search("", { "getRankingInfo": true, "analytics": false, "enableABTest": false, "hitsPerPage": 24, "attributesToRetrieve": "*", "attributesToSnippet": "*:20", "snippetEllipsisText": "…", "responseFields": "*", "explain": "*", "ruleContexts": ["doorbuster"], "maxValuesPerFacet": 24, "page": 0, "facets": ["*"], "facetFilters": [ ["PriceHandle:Clearance Price"] ] }).then(({ hits }) => { return hits; }); let resultData = async () => { const items = await results; console.log('items: ', items) if (items.length > 0) { save(id, items, 15); var preparedItems = prepareBoutiqueItems(items); $(boutique).html(renderList(template, preparedItems)); initCarousel(boutique, items); } else { $(boutique).html("

Check back soon!

"); } } resultData(); } } function initCarousel(el, value) { $(el).addClass("owl-carousel").owlCarousel({ dots: false, nav: true, navText: ["", ""], slideBy: 'page', responsive: { 0: { items: 1, loop: true }, 481: { items: 2, loop: true }, 768: { items: 5, loop: true }, 992: { items: 5, loop: true }, 1200: { items: 5, loop: true } } }); } function renderList(template, items, it) { var productList = window.location.pathname + "__" + title; var insertHtml = ""; items.forEach(function (item, index) { item.ProductList = productList; item.ProductPosition = index + 1; insertHtml += render(template, item, it); }); return insertHtml; } } function getRecommendations(offerCode) { var url = "/Product/GetRecommendationProducts"; var recommendationTypes = ["PeopleWhoViewedAlsoViewed", "FrequentlyPurchasedTogether", "PeopleWhoBoughtAlsoBought"]; var defaultParams = { offerCode: "", maxItems: 10, recommendationType: 0, category: "", brand: "" }; var ajaxPromises = []; var ajaxResults = {}; var deferred = $.Deferred(); $.each(recommendationTypes, function (index, type) { var params = JSON.parse(JSON.stringify(defaultParams)); params.offerCode = offerCode; params.recommendationType = index; var queryString = $.param(params); var query = $.post(url + "?" + queryString).done(function (response) { ajaxResults[type] = response[type]; }).fail(function (error) { console.log("Error getting recommendations for " + type, error); $("#variant-c-recommendations").hide(); }); ajaxPromises.push(query); }); $.when.apply($, ajaxPromises).done(function () { deferred.resolve(ajaxResults); }).fail(function () { console.log("Error getting all recommendations", error); $("#variant-c-recommendations").hide(); deferred.reject(); }); return deferred.promise(); } function pickRecommendationSet(data, minimum) { if (data["FrequentlyPurchasedTogether"] && data["FrequentlyPurchasedTogether"].length >= minimum) { console.log("Showing FrequentlyBought"); return data["FrequentlyPurchasedTogether"]; } if (data["PeopleWhoBoughtAlsoBought"] && data["PeopleWhoBoughtAlsoBought"].length >= minimum) { console.log("No FrequentlyBought, showing AlsoBought"); return data["PeopleWhoBoughtAlsoBought"]; } if (data["PeopleWhoViewedAlsoViewed"] && data["PeopleWhoViewedAlsoViewed"].length >= minimum) { console.log("No AlsoBought, showing AlsoViewed"); return data["PeopleWhoViewedAlsoViewed"]; } return null; } function prepareRecommendationItems(items) { items.forEach(function (item, index) { var percentOffText = item.PercentOff.DisplayPercentage.replace("(", "").replace(")", ""); if (parseInt(percentOffText) >= 15) { item.BadgeText = percentOffText; } else { item.BadgeText = ""; } item.ToplineAttr = item.Topline.replace(/"/g, ""); }); return items; } function prepareBoutiqueItems(items) { items.forEach(function (item, index) { var priceBadge = "hello"; if (item.OfferId) { item.OfferPriceLow = item.OfferPriceLow.toFixed(2); item.OfferPriceHigh = item.OfferPriceHigh.toFixed(2); var percentOffPriceLow = Math.round(((item.ListPriceLow - item.OfferPriceLow) / item.ListPriceLow) * 100); var percentOffPriceHigh = Math.round(((item.ListPriceHigh - item.OfferPriceHigh) / item.ListPriceHigh) * 100); if (item.OfferPriceLow === item.OfferPriceHigh) { item.OfferPrice = "$" + item.OfferPriceHigh; } else { item.OfferPrice = "$" + item.OfferPriceLow + " – " + "$" + item.OfferPriceHigh; } if (item.ListPriceLow === item.ListPriceHigh) { item.ListPrice = "$" + formatMoney(item.ListPriceHigh); } else { item.ListPrice = "$" + item.ListPriceLow + " – " + "$" + formatMoney(item.ListPriceHigh); } if (item.Title.toLowerCase().indexOf("waterford") >= 0 || percentOffPriceLow > 99 || percentOffPriceLow 99 || percentOffPriceHigh 3 ? j % 3 : 0; return (s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(d{3})(?=d)/g, "$1" + t) + (c && Math.abs(n - i).toFixed() > 0 ? d + Math.abs(n - i).toFixed(c).slice(2) : "")); } function save(key, jsonData, expirationMin) { var expirationMS = expirationMin * 60 * 1000; var record = { value: JSON.stringify(jsonData), timestamp: new Date().getTime() + expirationMS }; localStorage.setItem(key, JSON.stringify(record)); return jsonData; } function load(key) { var record = JSON.parse(localStorage.getItem(key)); if (!record) { return false; } return new Date().getTime()
`; var templateRecommendations = ``; if (recommendations) { var cookie = typeof $.cookie !== "undefined" ? $.cookie("RViewSHOP1") : false; if (typeof cookie !== "undefined" && cookie.length > 0) { var offerCode = decodeURIComponent(cookie).split("|").shift().replace("#", ""); console.log("Checking recommendations for Offer Code: " + offerCode); getRecommendations(offerCode).then(function(data) { var items = pickRecommendationSet(data, 4); if (items) { var preparedItems = prepareRecommendationItems(items); initBoutiqueCarousel(recommendations, templateRecommendations, preparedItems); } else { console.log("No recommendations found"); initBoutiqueCarousel(boutique, templateBoutique); } }); } else { console.log("No cookie found"); initBoutiqueCarousel(boutique, templateBoutique); } } else { initBoutiqueCarousel(boutique, templateBoutique); } function initBoutiqueCarousel(selector, template, items) { var el; if (typeof selector === "string") { el = document.querySelector(selector); if (!el) return; } else { el = selector; } var boutique = el.querySelector(".boutique-carousel__wrapper"); if (!boutique) return; el.style.display = "block"; var title = boutique.dataset.title.replace(/ /g, ""); if (typeof items === "undefined") { var url = boutique.dataset.boutiqueurl ? boutique.dataset.boutiqueurl : null; if (!url) return; if ("IntersectionObserver" in window) { var observer = new IntersectionObserver(function(entries) { entries.forEach(function(entry) { if (entry.intersectionRatio > 0) { getItems(); observer.unobserve(entry.target); } }); }, { rootMargin: "500px" }); observer.observe(boutique); } else { getItems(); } } else { $(boutique).html(renderList(template, items)); initCarousel(boutique); } function getItems() { var items = load(id) || null; if (items) { var preparedItems = prepareBoutiqueItems(items); $(boutique).html(renderList(template, preparedItems)); console.log('storage items: ', items) initCarousel(boutique, items); } else { let results = index.search("", { "getRankingInfo": true, "analytics": false, "enableABTest": false, "hitsPerPage": 24, "attributesToRetrieve": "*", "attributesToSnippet": "*:20", "snippetEllipsisText": "…", "responseFields": "*", "explain": "*", "ruleContexts": ["todays-special-deals"], "maxValuesPerFacet": 24, "page": 0, "facets": ["*"], "facetFilters": [ ["PriceHandle:Supercharged Deal", "PriceHandle: Today Only Price", "PriceHandle:Weekend Deal", "PriceHandle:Weekly Deal", "PriceHandle:Monthly Deal", "PriceHandle:Daily Digital Deals", "PriceHandle:Must Have Buy", "PriceHandle:Holiday Must Have Buy", "PriceHandle:This Day Only", "PriceHandle:Web Todays Top Value", "PriceHandle:This Event Only", "PriceHandle:This Weekend Only", "PriceHandle:Once Only", "PriceHandle:Today's Show Buster", "PriceHandle:Flash Deal This Show Only", "PriceHandle:Flash Deal This Hour Only", "PriceHandle:Flash Deal This Event Only", "PriceHandle:Flash Deal This Day Only", "PriceHandle:Flash Deal This Weekend Only", "PriceHandle:Flash Deal This Week Only", "PriceHandle:Flash Deal This Month Only"] ] }).then(({ hits }) => { return hits; }); let resultData = async () => { const items = await results; console.log('items: ', items) if (items.length > 0) { save(id, items, 15); var preparedItems = prepareBoutiqueItems(items); $(boutique).html(renderList(template, preparedItems)); initCarousel(boutique, items); } else { $(boutique).html("

Check back soon!

"); } } resultData(); } } function initCarousel(el, value) { // DEBUG UI OFFERCODE value.forEach(function(r, index) { $(`#QuickView_${r.OfferCode}`).click(function() { console.log('Debug offercode: ', r.OfferCode) }) }) $(el).addClass("owl-carousel").owlCarousel({ dots: false, nav: true, navText: ["", ""], slideBy: 'page', responsive: { 0: { items: 1, loop: true }, 481: { items: 2, loop: true }, 768: { items: 3, loop: true }, 992: { items: 5, loop: true }, 1200: { items: 5, loop: true } } }); } function renderList(template, items, it) { var productList = window.location.pathname + "__" + title; var insertHtml = ""; items.forEach(function(item, index) { item.ProductList = productList; item.ProductPosition = index + 1; insertHtml += render(template, item, it); }); return insertHtml; } } function getRecommendations(offerCode) { var url = "/Product/GetRecommendationProducts"; var recommendationTypes = ["PeopleWhoViewedAlsoViewed", "FrequentlyPurchasedTogether", "PeopleWhoBoughtAlsoBought"]; var defaultParams = { offerCode: "", maxItems: 10, recommendationType: 0, category: "", brand: "" }; var ajaxPromises = []; var ajaxResults = {}; var deferred = $.Deferred(); $.each(recommendationTypes, function(index, type) { var params = JSON.parse(JSON.stringify(defaultParams)); params.offerCode = offerCode; params.recommendationType = index; var queryString = $.param(params); var query = $.post(url + "?" + queryString).done(function(response) { ajaxResults[type] = response[type]; }).fail(function(error) { console.log("Error getting recommendations for " + type, error); $("#variant-c-recommendations").hide(); }); ajaxPromises.push(query); }); $.when.apply($, ajaxPromises).done(function() { deferred.resolve(ajaxResults); }).fail(function() { console.log("Error getting all recommendations", error); $("#variant-c-recommendations").hide(); deferred.reject(); }); return deferred.promise(); } function pickRecommendationSet(data, minimum) { if (data["FrequentlyPurchasedTogether"] && data["FrequentlyPurchasedTogether"].length >= minimum) { console.log("Showing FrequentlyBought"); return data["FrequentlyPurchasedTogether"]; } if (data["PeopleWhoBoughtAlsoBought"] && data["PeopleWhoBoughtAlsoBought"].length >= minimum) { console.log("No FrequentlyBought, showing AlsoBought"); return data["PeopleWhoBoughtAlsoBought"]; } if (data["PeopleWhoViewedAlsoViewed"] && data["PeopleWhoViewedAlsoViewed"].length >= minimum) { console.log("No AlsoBought, showing AlsoViewed"); return data["PeopleWhoViewedAlsoViewed"]; } return null; } function prepareRecommendationItems(items) { items.forEach(function(item, index) { var percentOffText = item.PercentOff.DisplayPercentage.replace("(", "").replace(")", ""); if (parseInt(percentOffText) >= 15) { item.BadgeText = percentOffText; } else { item.BadgeText = ""; } item.ToplineAttr = item.Topline.replace(/"/g, ""); }); return items; } function prepareBoutiqueItems(items) { items.forEach(function(item, index) { var priceBadge = "hello"; if (item.OfferId) { item.OfferPriceLow = item.OfferPriceLow.toFixed(2); item.OfferPriceHigh = item.OfferPriceHigh.toFixed(2); var percentOffPriceLow = Math.round(((item.ListPriceLow - item.OfferPriceLow) / item.ListPriceLow) * 100); var percentOffPriceHigh = Math.round(((item.ListPriceHigh - item.OfferPriceHigh) / item.ListPriceHigh) * 100); if (item.OfferPriceLow === item.OfferPriceHigh) { item.OfferPrice = "$" + item.OfferPriceHigh; } else { item.OfferPrice = "$" + item.OfferPriceLow + " – " + "$" + item.OfferPriceHigh; } if (item.ListPriceLow === item.ListPriceHigh) { item.ListPrice = "$" + formatMoney(item.ListPriceHigh); } else { item.ListPrice = "$" + item.ListPriceLow + " – " + "$" + formatMoney(item.ListPriceHigh); } if (item.Title.toLowerCase().indexOf("waterford") >= 0 || percentOffPriceLow > 99 || percentOffPriceLow 99 || percentOffPriceHigh 3 ? j % 3 : 0; return (s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(d{3})(?=d)/g, "$1" + t) + (c && Math.abs(n - i).toFixed() > 0 ? d + Math.abs(n - i).toFixed(c).slice(2) : "")); } function save(key, jsonData, expirationMin) { var expirationMS = expirationMin * 60 * 1000; var record = { value: JSON.stringify(jsonData), timestamp: new Date().getTime() + expirationMS }; localStorage.setItem(key, JSON.stringify(record)); return jsonData; } function load(key) { var record = JSON.parse(localStorage.getItem(key)); if (!record) { return false; } return new Date().getTime()