Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var __isp_options = {
- isp_serp_callback: function() {
- if (typeof cart_items === 'undefined') {
- var cart_items = [];
- $jquery_isp.ajax({
- type: 'GET',
- url: '/cart.js',
- dataType: 'json',
- async: false,
- success: function (data) {
- for (var i = 0; i < data.items.length; i++) {
- var id = data.items[i].product_id;
- var var_id = data.items[i].variant_id;
- cart_items.push({id: id, var_id: var_id});
- }
- }
- });
- }
- if (window.location.pathname.indexOf("/collections/sale") != -1) {
- $(".isp_facet_title_name").each(function (index) {
- console.log("This text", $(this).text());
- if ("Sale" == $(this).text()) {
- $(".isp_single_facet_wrapper").eq(index).remove()
- }
- });
- }
- $jquery_isp('.isp_grid_product:not(.isp_grid_product_skeleton)').each(function() {
- var id = $jquery_isp(this).attr('product_id');
- $jquery_isp(this).attr('id', 'grid-item-' + id);
- $jquery_isp(this).addClass('product-item');
- // Fix Flow compare_at localizations
- $jquery_isp(this).find('.isp_compare_at_price').attr('flow-selector','prices.compare_at.label');
- if (ISP_PRODUCTS[id]) {
- var variants = ISP_PRODUCTS[id].vra;
- /**
- * Create "Add to Bag" select button
- */
- if(variants.length <= 1){
- var variant = variants[0],
- size = variant[1].find(function (element) { return element[0] === "Size" })[1][0],
- sellable = variants[0][1].find(function (element) { return element[0] === "Sellable" })[1][0];
- variant_id = variant[0];
- var one_size_form = '<form action="/cart/add" method="post" class="variants add-to-cart-form product-info-json product-atc info" id="product-actions-' + id + '" enctype="multipart/form-data">' +
- '<input type="hidden" name="id" value="'+variant_id+'">' +
- '</form>';
- this.insertAdjacentHTML('beforeend', one_size_form);
- var add_to_cart_button = ''
- if(sellable) {
- if ($jquery_isp(this).find('.product-atc-label').length === 0) {
- add_to_cart_button = '<div class="product-atc-label women">'+
- '<span class="main-option-title left-side"><div></div></span>'+
- '<span class="atc-label">Add to bag</span>'+
- '<span class="main-option-title"><div></div></span>'+
- '</div>'+
- '<input type="button" class="product-main-option" data-main-option-text="' + size + '" data-option-name="Size" data-variant-id="' + variant_id + '" id="product-'+id+'-variantid" name="id" value="' + variant_id + '">';
- }
- } else {
- add_to_cart_button = '<a class="btn notify-me not-available os" href="#" data-notifyme-btn="">Notify Me When Available</a>';
- }
- this.querySelector('.add-to-cart-form').insertAdjacentHTML('beforeend', add_to_cart_button);
- } else {
- if ($jquery_isp(this).find('.product-atc').length === 0) {
- var add_to_bag_select = '<form action="/cart/add" method="post" class="variants add-to-cart-form product-info-json product-atc info" id="product-actions-' + id + '" enctype="multipart/form-data">' +
- '<a class="btn dropdown product-atc-label women" data-show-sizes="">' +
- '<span class="main-option-title left-side"><div></div></span>' +
- '<span class="atc-label">Add to bag</span>' +
- '<span class="main-option-title"><div></div></span>' +
- '</a>' +
- '<div class="product-main-options" style="display: none; width: 100%;">' +
- '<input type="hidden" name="id" value="">' +
- '<div class="product-main-options__wrapper">' +
- '<div class="product-main-options__size" aria-live="polite">Select Size</div>' +
- '<a class="product-main-options__close" aria-label="Close Size Window" data-close-size>' +
- '<span class="lnr animation lnr-cross make-gray" aria-hidden="true"></span>' +
- '</a>' +
- '<div class="product-main-options__content">' +
- '<ul class="product-main-option__list"></ul>' +
- '<button class="btn dropdown women" data-add-to-cart="" name="add" style="display: none;"></button>' +
- '<a class="btn notify-me" data-notifyme-btn style="display: none;">Notify Me When Available</a>' +
- '<a class="product-main-options__size-guide" data-size-guide style="display: block;">Size Guide</a>' +
- '</div>' +
- '</div>' +
- '</div>' +
- '</form>';
- this.insertAdjacentHTML('beforeend', add_to_bag_select);
- }
- }
- /**
- * Notify Me
- */
- // if ($jquery_isp(this).find('.notifyme-item').length === 0) {
- // var title = ISP_PRODUCTS[id].l;
- // var image = ISP_PRODUCTS[id].image;
- // var image_400 = ISP_PRODUCTS[id].image.replace('600', '400');
- // var image_200 = ISP_PRODUCTS[id].image.replace('600', '200');
- // var notify_me = '<section id="notifyme-item-' + id + '" data-notifyme-form="" class="notifyme-item" data-section-id="notifyme-item-' + id + '" data-section-type="notifyme-item" data-product-detail="" data-notifyme="true">' +
- // '<form class="notifyme-form" id="notifyme-form-' + id + '">' +
- // /*'<input type="hidden" name="gender" id="gender-' + id + '" value="women">' +*/
- // '<input type="hidden" name="source" id="source-' + id + '" value="BIS_Collection">' +
- // '<div class="notifyme--top notifyme--top__default">' +
- // '<h2>We can email you when its back!</h2>' +
- // '<a href="#" class="notifyme--form__close" aria-label="Close Size Window" data-close="">' +
- // '<span class="lnr animation lnr-cross make-gray" aria-hidden="true"></span>' +
- // '</a>' +
- // '</div>' +
- // '<div class="notifyme--top notifyme--top__thanks">' +
- // '<h2>Perfect!</h2>' +
- // '<a href="#" class="notifyme--form__close" aria-label="Close Size Window" data-close="">' +
- // '<span class="lnr animation lnr-cross make-gray" aria-hidden="true"></span>' +
- // '</a>' +
- // '</div>' +
- // '<a href="#" class="back-to-sizes" data-back-to-sizes="grid-item-' + id + '">< back to sizes</a>' +
- // '<div class="notifyme--product">' +
- // '<div class="image" id="image-' + id + '">' +
- // '<div class="mediabox lazyloaded" data-expand="-1">' +
- // '<img class="mediabox-img lazyautosizes lazyloaded" data-sizes="auto" data-src="' + image + '" data-srcset="' + image_200 + ' 200w,' + image_400 + ' 400w" src="' + image + '" alt="' + title + '" srcset="' + image_200 + ' 200w,' + image_400 + ' 400w">' +
- // '</div>' +
- // '</div>' +
- // '<div class="product-info">' +
- // '<div class="notifyme--copy">' +
- // '<p>Register so we can email you as soon as your size becomes available!</p>' +
- // '</div>' +
- // '<div class="product-info--name">' + title + '</div>' +
- // '<span class="product-info--size">Size:</span><span class="product-info--selected">M</span>' +
- // '<div class="options animation clearfix "> ' +
- // '<label id="selector-label" for="product-select-' + id + '" class="single offscreen" aria-label="Select Size">Select Size:</label>' +
- // '<select class="select-variant" id="product-select-' + id + '"></select>' +
- // '<input type="hidden" name="id" id="product-' + id + '-variant" value="12472888098925">' +
- // '</div>' +
- // '</div>' +
- // '<div class="thank-you">' +
- // '<p>We\'ll email you at <span data-email=""></span> when the item is back in stock!</p>' +
- // '</div>' +
- // '</div>' +
- // '<div class="notifyme--form">' +
- // '<input type="email" data-notify-email="" id="email" name="email" placeholder="Enter your email address">' +
- // '<div class="email-error">Please enter a valid email address</div>' +
- // '<button type="submit" class="btn notify-me-submit" data-notifyme-btn>Notify Me <span class="fa fa-envelope-o" aria-label="hidden"></span></button>' +
- // '<label for="subscribe-notify-' + id + '">' +
- // '<input type="checkbox" name="subscribe" data-subscribe="" id="subscribe-notify-' + id + '" checked="">Get Email Updates' +
- // '</label>' +
- // '<p class="notifyme--notice"><i>Yes, I would like to be notified by email about this product, and to receive emails from Fashion Nova with the latest deals, sales, and updates. I agree to Fashion Nova’s <a href="/pages/terms-of-service" target="_blank">Terms of Service</a> and <a href="/pages/privacy-policy" target="_blank">Privacy Policy.</a></i></p>' +
- // '</div>' +
- // '<a href="#" data-close="" class="btn close-modal">Continue Shopping</a>' +
- // '</form>' +
- // '</section>';
- // this.insertAdjacentHTML('beforeend', notify_me);
- // }
- /**
- * Add variant sizes
- */
- var size_list = [];
- var size_options = [];
- for (var i = 0; i < cart_items.length; i++) {
- if (cart_items[i].id == id) {
- var cart_item_variant = variants.find(function (element) { return element[0] === cart_items[i].var_id }) ? variants.find(function (element) { return element[0] === cart_items[i].var_id })[1] : [];
- if (cart_item_variant.length > 0) {
- var size = cart_item_variant.find(function (element) { return element[0] === "Size" }) ? cart_item_variant.find(function (element) { return element[0] === "Size" })[1][0] : '';
- if (size) {
- $jquery_isp('[product_id="' + id + '"] .product-atc-label').addClass('option-selected in-cart');
- $jquery_isp('[product_id="' + id + '"] .atc-label').html('In your bag!');
- $jquery_isp('[product_id="' + id + '"] .main-option-title > div').html(size);
- }
- }
- }
- }
- if(variants.length > 1){
- for (var i = 0; i < variants.length; i++) {
- var vra_id = variants[i][0];
- if (variants[i][1].find(function(element) { return element[0] === "Size" }) && $jquery_isp('[data-variant-id="' + vra_id + '"]').length == 0) {
- var size = variants[i][1].find(function (element) { return element[0] === "Size" })[1][0];
- var sellable = variants[i][1].find(function (element) { return element[0] === "Sellable" })[1][0];
- var size_li = sellable ? '<li><a data-variant-id="' + vra_id + '" data-main-option-text="' + size + '" data-size>' + size + '</a></li>'
- : '<li><a data-variant-id="' + vra_id + '" data-main-option-text="' + size + '" data-sold-out>' + size + '<span class="sold-out-msg">Sold Out - <span class="sold-out-msg sold-out-msg__notify">Notify Me</span></span></a></li>';
- size_list.push(size_li);
- }
- }
- this.querySelector(".product-main-option__list").insertAdjacentHTML('beforeend', size_list.join(''));
- }
- /**
- * Product Size Guide
- */
- if ($jquery_isp(this).find('.product-size-guide').length === 0 && $jquery_isp(this).find('.add-to-cart-form').length > 0) {
- var size_guide = '<section class="product-size-guide">\
- <div class="product-size-guide__header">Size Guide</div>\
- <a href="#" class="product-main-options__close" aria-label="Close Size Guide Window" data-close-size-guide>\
- <span class="lnr animation lnr-cross make-gray" aria-hidden="true"></span>\
- </a>\
- <a href="#" class="back-to-sizes" data-back-to-sizes="grid-item-' + id + '">< back to sizes</a>\
- <a href="#" class="btn btn-size-guide active" data-guide-type="womens">Womens</a><a href="#" class="btn btn-size-guide" data-guide-type="mens">Mens</a>\
- <div class="product-size-guide--content product-size-guide__womens active"></div>\
- <div class="product-size-guide--content product-size-guide__mens"></div>\
- </section>';
- $jquery_isp(this).find('.add-to-cart-form')[0].insertAdjacentHTML('beforeend', size_guide);
- }
- try {
- addToCartButton($jquery_isp('[product_id="' + id + '"]'));
- }
- catch(e) {
- console.log(e)
- }
- }
- });
- // Trigger Flow Localization
- try {
- Flow.variants.localize({
- force:true,
- container: document.querySelector('#isp_search_results_container')
- });
- } catch (error) {
- console.error('Could not localize variant: ' + error);
- }
- },
- isp_serp_no_results_callback: function () {
- location.replace('https://www.fashionnova.com/pages/no-results-page');
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement