Sieraden bij Juwelier & Sieradenatelier Sluijsmans (2024)

Sieraden bij Juwelier & Sieradenatelier Sluijsmans (1)

")},ajaxLoadProduct:function(){var o=0;t.click(function(n){n.preventDefault(),e(this).text("Loading123 ..."),e.ajax({url:"ajax/category-ajax-products.html",success:function(n){var i=e(n);setTimeout(function(){i.appendTo(".product-ajax-grid"),t.text("Load More"),++o>=2&&t.hide()},350)},failure:function(){t.text("Sorry something went wrong.")}})})},toggleFilter:function(){e(".filter-toggle a").click(function(o){e(".filter-toggle").toggleClass("opened"),e("main").toggleClass("sidebar-opened")}),e(".sidebar-overlay").click(function(o){e(".filter-toggle").removeClass("opened"),e("main").removeClass("sidebar-opened")}),e(".sort-menu-trigger").click(function(o){o.preventDefault(),e(".select-custom").removeClass("opened"),e(o.target).closest(".select-custom").toggleClass("opened")})},toggleSidebar:function(){e(".sidebar-toggle").click(function(){e("main").toggleClass("sidebar-opened")})},scrollToElement:function(){},loginPopup:function(){e(".login-link").click(function(t){t.preventDefault(),o.ajaxLoading(),setTimeout(function(){e.magnificPopup.open({type:"ajax",mainClass:"login-popup",tLoading:"",preloader:!1,removalDelay:350,items:{src:"ajax/login-popup.html"},callbacks:{beforeClose:function(){e(".ajaxOverlay").remove()}},ajax:{tError:""}})},1500)})},windowClick:function(){e(document).click(function(o){e(o.target).closest(".toolbox-item.select-custom").length||e(".select-custom").removeClass("opened")})}},t=e(".loadmore .btn");jQuery(document).ready(function(){o.init()}),e(window).on("load",function(){o.scrollBtnAppear()}),e(window).on("scroll",function(){o.scrollBtnAppear()})}(jQuery);`) .appendTo('.default-filter-widget'); }) } loaded = true; }; handleImageLoadError = function(event){ if((event.getAttributeNames()).indexOf('ng-src') > -1){ event.src = "https://prismanote.s3.amazonaws.com/websitebuilder-default-templates/image-website-builder/no-photo-available.jpg"; } }; onBeforeUnload = function (e) { setCookie('recentSrollPos', JSON.stringify(window.scrollY)); }; window.onbeforeunload = onBeforeUnload; // $(window).on('beforeunload', function (e) { // setCookie('recentSrollPos', JSON.stringify(window.scrollY)); // }); var app = angular.module("editorApp", []).run(function ($rootScope) { $rootScope.apiBasepath = window.apiBasePath; $rootScope.storeNameSlug = window.storeNameSlug; $rootScope.storeId = window.storeId; $rootScope.websiteName = 'test1'; $rootScope.corsHeaders = { 'Access-Control-Allow-Credentials': true, 'Access-Control-Allow-Origin': true, 'Access-Control-Allow-Headers': true, 'Access-Control-Expose-Headers': true }; $rootScope.selectedLanguage = window.selectedLanguage ? window.selectedLanguage : (localStorage.getItem('selectedLanguage') ? localStorage.getItem('selectedLanguage') : 'nl'); localStorage.setItem('selectedLanguage', $rootScope.selectedLanguage) // $('.product-list-page-container').removeClass('hide'); websiteName = $rootScope.websiteName; shopId = $rootScope.storeId; if(production && !window.INLINE_EDITOR_ID){ $('.show-on-editor').addClass('d-none'); $('.default-filter-widget').removeClass('d-none'); $('.default-filter-widget').removeClass('hide'); } var testingDomains = [ "localhost", "127.0.0.1", "www.goedenoot.nl", "goedenoot.nl", "prismanote.it", "www.prismanote.it", "sterjuwelier.nl", "www.sterjuwelier.nl", $rootScope.apiBasepath ]; $rootScope.awsUrl = "https://prismanote.s3.amazonaws.com/"; }); app.factory('interceptor', function ($q){ return { request: function (config) { config = angular.copy(config) if(config.method === 'POST' || config.method === 'PUT') { var encrypted = CryptoJS.AES.encrypt(JSON.stringify(config.data), '2e35f242a46d67eeb74aabc37d5e5d05').toString() config.data = { encrypted: encrypted } } return config || $q.when(config) }, requestError: function (rejection) { return $q.reject(rejection) }, response: function (response) { return response }, responseError: function (rejection) { return rejection } } }) app.config(function($interpolateProvider, $httpProvider) { $interpolateProvider.startSymbol('{[{'); $interpolateProvider.endSymbol('}]}'); $httpProvider.interceptors.push('interceptor') }); app.directive('controllerData', function () { return function (scope, element, attrs) { scope.setConfigData(attrs); $(element).bind('contentchanged', function(e) { var attributes = []; attributes["config"] = e.currentTarget.attributes["data-config"].value; scope.setConfigData(attributes); }); }; }); app.directive("directiveWhenScrolled", function($window) { return function(scope, elm, attr) { angular.element($window).bind('scroll', function() { scope.scrolledArea = $('#customProductListId').height(); if (scope.scrolledArea && scope.scrolledArea!= 0 && this.pageYOffset >= scope.scrolledArea - 600 ) { scope.$apply(attr.directiveWhenScrolled); } }); }; }); app.controller("defaultFilterController", function($scope, $rootScope, $http, $q, $sce, $location) { $scope.products = []; $scope.loading = true; $scope.ajaxLoadProduct = false; $scope.showAddcartModal = false; $scope.defaultShipper = false; $scope.defaultCompanyId = ''; $scope.defaultBrandId = ''; $scope.setScrollPos = false; // Pagination usefull variables declaration start. $scope.loadMore = true; $scope.showMoreFilters = false; $scope.isAnyFilterApplied = false; $scope.scrolledArea = 0; $scope.totalProduct = 0; $scope.filteredBrands = {}; $scope.brandFilterObj = {}; // Default filter config $scope.configData = {}; $scope.shopDetails = {}; $scope.collections = []; $scope.fetchedCollections = false; $scope.fetchedShopDetails = false; $scope.fetchedBrandList = false; $scope.setConfigFilter = false; $scope.showTranslations = {}; $scope.cartItems = []; $scope.baseOrigin = window.location.origin; $scope.isBackFromDetails = getCookie('isBackFromDetails'); $scope.localTest = localStorage.getItem('Test22'); $scope.isFiltersSet = false; $scope.navItemList = []; $scope.isNavDetailsExist = []; const self = $scope; window.dmAPI.getNavItemsAsync().then((res)=> { if(res && res.length > 0){ // self.navItemList = res; self.isNavDetailsExist = res.filter(n => { if(n.title == 'details'){ return true; }else if(n.subNav && n.subNav.length > 0){ let navDetail = n.subNav.filter(nav => nav.title == 'details'); return navDetail.length > 0 ? true : false; } else { return false; } }); } }); // $scope.navItemList = JSON.parse(atob(window.Parameters.NavItems)); $scope.defaultFilters = []; $scope.saleLabelStyle = { 'background-color': '#e1ddc3', 'color': '#333333' }; // Category filter start $scope.availableCategoryFilters = ['WATCH', 'STRAP', 'JEWEL', 'OTHER']; const productExistCart = { en: 'Product already exists in your shopping cart.', nl: 'Product bestaat al in uw winkelwagen.', de: 'Das Produkt befindet sich bereits in Ihrem Warenkorb.', fr: 'Le produit existe déjà dans votre panier.', es: 'El producto ya existe en su carrito de compras.' }; // category: 'Jewel' related filter $scope.jewelFilter = { type: [ "BROOCH", "CHOKER", "PENDANT", "NECKLACE", "TENNIS_NECKLACE", "STUD_EARRINGS", "HOOP_EARRINGS", "CREOLE_EARRINGS", "RING", "COMBINATION_RING", "RING_WITH_PEARL", "RING_WITH_GEM", "SET", "BRACELET", "TENNIS_BRACELET", "SLAVE_BRACELET", "ANKLE_BRACELET", "CUFFLINK", "SEAL_RING" ] }; $scope.pagePerLimitOptions = [ { text: '8 Products', value: 8 }, { text: '16 Products', value: 16 }, { text: '24 Products', value: 24 } ]; // Pagination usefull variables declaration end. // Material fiter start $scope.commonMaterial = [ { value: "WHITEGOLD", key: "Whitegold" }, { value: "PALLADIUM", key: "Palladium" }, { value: "GOLD", key: "Gold" }, { value: "REAL_GOLD", key: "Realgold" }, { value: "SILVER", key: "Silver" }, { value: "TITANIUM", key: "Titanium" }, { value: "STAINLESS_STEEL", key: "Stainless steel" }, { value: "ALUMINIUM", key: "Aluminium" }, { value: "METAL", key: "Metal" }, { value: "WOOD", key: "Wood" }, { value: "CERAMICS", key: "Ceramics" }, { value: "PU_LEATHER", key: "PU leather" }, { value: "REAL_LEATHER", key: "Real leather" }, { value: "UPPER_LEATHER", key: "Upper leather" }, { value: "PLASTIC_SILICONE", key: "Plastic / Silicone" }, { value: "CANVAS", key: "Canvas" }, { value: "CERAMICS", key: "Ceramics" }, { value: "PLATINUM", key : "Platinum" }, { value: "Bronze", key: "Bronze" } ]; // Material fiter end // Color related filters start $scope.commonColor = [ { key: 'SILVER_COLORED', hex: '#CACFD2' }, { key: 'GREY', hex: '#4D5656' }, { key: 'BLUE', hex: '#2980B9' }, { key: 'WHITE', hex: '#FFF8DC' }, { key: 'RED', hex: '#922B21' }, { key: 'BLACK', hex: '#000000' }, { key: 'ROSE_GOLD_COLORED', hex: '#FFA07A' }, { key: 'ROSE_SILVER_COLORED', hex: '#FFA07A' }, { key: 'GOLD_COLORED', hex: '#B8860B' }, { key: 'BROWN', hex: '#8B4513' }, { key: 'BEIGE', hex: '#CD853F' }, { key: 'GOLDEN', hex: '#B8860B' }, { key: 'GREEN', hex: '#228B22' }, { key: 'PINK', hex: '#FF69B4' }, { key: 'PURPLE', hex: '#663399' }, { key: 'ORANGE', hex: '#FF5733' }, { key: 'YELLOW', hex: '#FFD700' }, { key: 'CREME', hex: '#F5DEB3' }, { key: 'TAUPE', hex: '#D2B48C' }, { key: 'BRASS', hex: '#CD853F' }, { key: 'MOTHER_OF_PEARL_COLOURED', hex: '#BC8F8F' }, { key: 'MOTHER_OF_PEARL', hex: '#BC8F8F' }, ]; // Color related filters end // category: 'Watch' related filter $scope.watchFilter = { particulars: { hasSwissMovement: 'Swiss movement', hasDateFunction: 'Date display', isAntiAllergy: 'Anti allergic', isNickelFree: 'Nickel free', hasLightFunction: 'Light function' }, movement: { QUARTZ: 'Quartz', SOLAR: 'Solar', GPS_SOLAR: 'GPS Solar', KINETIC: 'Kinetic', AUTOMATIC: 'Automatic', HAND_WINDING: 'Hand Winding' }, timeIndication: { ANALOG: 'Analog', CHRONO_MULTI: 'Chronograph', ANALOG_DIGITAL: 'Analog and digital', DIGITAL: 'Digital', }, index: { ARABIC: 'numbers-Arabic', ROMAN: 'Roman numerals', STRIPES: 'Stripes', DOTS: 'Dots', ORNAMENTAL_DIAMONDS: 'Real diamonds / ornamental diamonds', NONE: 'None' }, type: ['WRIST', 'POCKET', 'NURSE'], glassType: { SAPPHIRE: 'Sapphire', SAPPHIRE_COATED: 'Sapphire coated', CRYSTAL: 'Crystal', MINERAL: 'Mineral', SYNTHETIC_PLASTIC: 'Plastique/synthétique' }, case: { model: ["ROUND", "RECTANGLE", "OVAL", "SQUARE", "OTHER_SHAPE"], glass: ["SAPPHIRE", "SAPPHIRE_COATED", "CRYSTAL", "MINERAL", "SYNTHETIC_PLASTI"] }, strap: { model: ["STANDARD_MODEL", "SELECT_BAND", "MILANESE_MESH", "NATO", "CHAIN_OF_A_POCKET_WATCH", "EXPANDABLE_STRETCH_STRAP", "SELECT_BAND_FOR_POCKET_WATCH"], type: { STANDARD_MODEL: 'Standard strap', MILANESE_MESH: 'Milanese/mesh', SELECT_BAND: 'Select band', EXPANDABLE_STRETCH_STRAP: 'Expandable/stretch strap', NATO: 'Nato', CHAIN_OF_A_POCKET_WATCH: 'Chain of a pocket watch' } } }; // category: 'Strap' related filter $scope.strapFilter = { type: [ "STANDARD_MODEL", "SELECT_BAND", "MILANESE_MESH", "NATO", "CHAIN_OF_A_POCKET_WATCH", "EXPANDABLE_STRETCH_STRAP", "SELECT_BAND_FOR_POCKET_WATCH" ] }; $scope.strapColors = [ { key: 'SILVER', hex: '#CACFD2' }, { key: 'GREY', hex: '#4D5656' }, { key: 'BLUE', hex: '#2980B9' }, { key: 'WHITE', hex: '#FFF8DC' }, { key: 'RED', hex: '#922B21' }, { key: 'BLACK', hex: '#000000' }, { key: 'ROSE_GOLD', hex: '#FFA07A' }, { key: 'GOLD', hex: '#B8860B' }, { key: 'BROWN', hex: '#8B4513' }, { key: 'BEIGE', hex: '#CD853F' }, { key: 'GOLDEN', hex: '#B8860B' }, { key: 'GREEN', hex: '#228B22' }, { key: 'PINK', hex: '#FF69B4' }, { key: 'PURPLE', hex: '#663399' }, { key: 'ORANGE', hex: '#FF5733' }, { key: 'YELLOW', hex: '#FFD700' }, { key: 'CREME', hex: '#F5DEB3' }, { key: 'TAUPE', hex: '#D2B48C' }, { key: 'BRASS', hex: '#CD853F' } ]; $scope.initializeVariables = function(){ $scope.loadedProductsCount = 0; $scope.shopIndex = 0; $scope.companyIndex = -1; $scope.sepratedTotalCount ={ multiShop: 0, dropshipper: 0 }; $scope.limit = 32; $scope.offset = 0; $scope.pageNumber = -1; $scope.collectionFilterIdWithNameSlug = {}; $scope.collectionShopIndex = 0; $scope.brandFilterIdWithNameSlug = {}; // Filtaration usefull variables declaration start $scope.shopFilter = { "inStock": true, "show": true, "hasStock": false, "price": { "gte": 0, "lte": 100000 } }; $scope.sort = {}; var tempProductFilter = $scope.productFilter; $scope.productFilter = {}; $scope.orderBy = {}; // Filtaration usefull variables declaration end. // Gender filteration variables if($scope.defaultFilters['gender']){ $scope.productFilter['gender'] = tempProductFilter['gender']; } else { $scope.menFilter = false; $scope.ladiesFilter = false; $scope.boyFilter = false; $scope.girlFilter = false; } // Gender filteration variables // Discount/Bestseller filteration variables $scope.discountFilter = false; $scope.bestsellerFilter = false; $scope.isfeaturedFilter = false; $scope.selectedJewelFilter = { color: [], material: [], size: { min: 1, max: 1 } }; if($scope.defaultFilters['jewelType']){ if ($scope.selectedJewelFilter.type && $scope.selectedJewelFilter.type.length > 0) { var jewelFilter = []; jewelFilter['type'] = { "$in": $scope.selectedJewelFilter.type }; $scope.productFilter['jewel'] = jewelFilter; } } else { $scope.selectedJewelFilter.type = []; } if($scope.defaultFilters['category']){ $scope.productFilter["category"] = { "$in": [$scope.selectedCategory.toUpperCase()] }; } else { $scope.selectedCategory = ''; } $scope.selectedWatchFilter = { particulars: [], timeIndication: [], movement: [], index: [], glassType: [], type: [], case: { size: { min: 0, max: 0 }, material: [], color: [], model: [] }, strap: { width: { min: 0, max: 0 }, type: [], color: [], material: [] }, dial: { color: [] }, waterTightness: { min: 0, max: 0 }, }; $scope.selectedStrapFilter = { type: [], color: [], material: [], width: { min: 0, max: 0 } }; $scope.minPrice = 0; $scope.maxPrice = 100000; $scope.showCollectionFilter = true; $scope.setFilterCount = { category: true, personal: true, watch: { features: true, indication: true, dial:{ index: true, color: true }, case: { material: true, shape: true, size: true, color: true } }, jewel: { type: true, material: true, color: true }, strap: { width: true, model: true, strapMaterial: true, color: true }, gender: true, brands: true }; $scope.showJewelSizeFilter = false; } $scope.initializeVariables(); $scope.getCartDetails = function(){ } $scope.getCartDetails(); $scope.device = window.device || window.INSITE.device; $scope.productTitleLength; if($scope.device === 'mobile'){ $scope.productTitleLength = 34; }else { $scope.productTitleLength = 52; } // sort filter data by alphabetical orders $scope.sortFilterData = function(){ $scope.jewelFilter.type.sort((a,b) => { let a_name = $scope.showTranslations[a]; let b_name = $scope.showTranslations[b]; return (a_name > b_name) ? 1 : ((b_name > a_name) ? -1 : 0); }); $scope.commonColor.sort((a,b) => { let a_name = $scope.showTranslations[a.key]; let b_name = $scope.showTranslations[b.key]; return (a_name > b_name) ? 1 : ((b_name > a_name) ? -1 : 0); }); $scope.strapColors.sort((a,b) => { let a_name = $scope.showTranslations[a.key]; let b_name = $scope.showTranslations[b.key]; return (a_name > b_name) ? 1 : ((b_name > a_name) ? -1 : 0); }); $scope.commonMaterial.sort((a,b) => { let a_name = $scope.showTranslations[a.value]; let b_name = $scope.showTranslations[b.value]; return (a_name > b_name) ? 1 : ((b_name > a_name) ? -1 : 0); }); } var myVar = setInterval(function(){ if(localStorage.getItem("allTranslations")){ clearInterval(myVar); $scope.showTranslations = JSON.parse(localStorage.getItem("allTranslations")); $scope.sortFilterData(); } }, 500); if(localStorage.getItem("allTranslations")){ clearInterval(myVar); $scope.showTranslations = JSON.parse(localStorage.getItem("allTranslations")); $scope.sortFilterData(); } $scope.setConfigData = function(element){ if(element.config){ $scope.configData = JSON.parse(atob(element.config)); $scope.configData['filterLayout'] = $scope.configData.filterLayout ? $scope.configData.filterLayout : 'above'; $scope.configData['productLimit'] = $scope.configData.productLimit ? $scope.configData.productLimit : 10; if($scope.fetchedShopDetails && $scope.fetchedCollections && $scope.fetchedBrandList){ $scope.setFilters(); } } }; $scope.setFilters = function (){ let preProductFilter = JSON.parse(getCookie('preProductFilter')); let shopFilter = {}; if($scope.isBackFromDetails && preProductFilter && Object.keys(preProductFilter).length > 0 ){ let preShopFilter = JSON.parse(getCookie('preShopFilter')); let preWatchParticularsFilter = JSON.parse(getCookie('preWatchParticularsFilter')); $scope.orderBy = JSON.parse(getCookie('preOrderBy')); // shop price filter if(preShopFilter && preShopFilter["price"] && typeof(preShopFilter["price"]["gte"]) != 'undefined' && typeof(preShopFilter["price"]["lte"]) != 'undefined'){ $scope.minPrice = preShopFilter["price"]["gte"]; $scope.maxPrice = preShopFilter["price"]["lte"]; $scope.shopFilter.price['gte'] = $scope.minPrice; $scope.shopFilter.price['lte'] = $scope.maxPrice; } // Shop hasStock filter if(preShopFilter && preShopFilter["hasStock"]){ $scope.shopFilter.hasStock = true; } // shop bestseller filter if(preShopFilter && preShopFilter["isBestseller"]){ if ($scope.configData.applyDiscount && $scope.configData.discountFilter == "bestseller") { $scope.defaultFilters['discount'] = true; } $scope.shopFilter['isBestseller'] = preShopFilter["isBestseller"]; $scope.bestsellerFilter = preShopFilter["isBestseller"]; } if(preShopFilter && preShopFilter["discount"]){ if ($scope.configData.applyDiscount && $scope.configData.discountFilter == "discount") { $scope.defaultFilters['discount'] = true; } $scope.shopFilter['discount'] = preShopFilter["discount"]; $scope.discountFilter = preShopFilter["discount"]; } if(preShopFilter && preShopFilter["isFeatured"]){ if ($scope.configData.applyDiscount && $scope.configData.discountFilter == "featured") { $scope.defaultFilters['discount'] = true; } $scope.shopFilter['isFeatured'] = preShopFilter["isFeatured"]; $scope.isfeaturedFilter = preShopFilter["isFeatured"]; } if(preProductFilter && preProductFilter["category"] && preProductFilter["category"]["$in"] && preProductFilter["category"]["$in"].length > 0){ if ($scope.configData.category && $scope.configData.category != "ALL") { $scope.defaultFilters['category'] = true; } $scope.selectedCategory = preProductFilter["category"]["$in"][0]; } // Check for collection filter if (preProductFilter["collection"] && preProductFilter["collection"].length > 0) { if (!$scope.configData.showAllCollection && $scope.configData.collectionList && $scope.configData.collectionList.trim() != "") { let collectionNameList = ($scope.configData.collectionList.toLowerCase()).split(","); if(collectionNameList.length > 0){ $scope.defaultFilters['collection'] = true; } } $scope.productFilter['collection'] = preProductFilter["collection"]; $scope.collectionFilterIdWithNameSlug = JSON.parse(getCookie('preCollectionFilter')); } // Check for brand filter if (preProductFilter && preProductFilter["brand"] && preProductFilter["brand"]["$in"] && preProductFilter["brand"]["$in"].length > 0) { if (!$scope.configData.showAllBrands && $scope.configData.brandList && $scope.configData.brandList.trim() != "") { let brandNameList = ($scope.configData.brandList.toLowerCase().trim()).split(","); if(brandNameList.length > 0){ $scope.defaultFilters['brand'] = true; } } $scope.productFilter['brand'] = { '$in': preProductFilter["brand"]["$in"] }; $scope.brandFilterIdWithNameSlug = JSON.parse(getCookie('preBrandFilter')); } // check for gender filter if(preProductFilter && preProductFilter["gender"]){ $scope.productFilter['gender'] = preProductFilter["gender"]; if ($scope.configData.gMen || $scope.configData.gLadies || $scope.configData.gBoy || $scope.configData.gGirl) { $scope.defaultFilters['gender'] = true; } $scope.productFilter['gender'].filter(g =>{ if(g["product.male"]){ if(g["product.kids"]){ $scope.boyFilter = true; } if(!g["product.kids"]){ $scope.menFilter = true; } } if(g["product.female"]){ if(g["product.kids"]){ $scope.girlFilter = true; } if(!g["product.kids"]){ $scope.ladiesFilter = true; } } }); } if(preProductFilter && preProductFilter["jewel"] && $scope.selectedCategory == "JEWEL"){ if(preProductFilter["jewel"] && preProductFilter["jewel"]["material"] && preProductFilter["jewel"]["material"]["$in"]){ $scope.commonMaterial.map(color=> { if($scope.configData[color.value]){ $scope.defaultFilters['jewelMaterial'] = true; } }); $scope.selectedJewelFilter.material = preProductFilter["jewel"]["material"]["$in"]; } if(preProductFilter["jewel"] && preProductFilter["jewel"]["type"] && preProductFilter["jewel"]["type"]["$in"]){ if($scope.configData.category == "JEWEL"){ var convertedArray = Object.keys($scope.configData).map(key => ({ key, value: $scope.configData[key] })); var filteredArray = convertedArray.filter(function(item){ if($scope.jewelFilter.type.indexOf(item.key) > -1 && item.value){ $scope.defaultFilters['jewelType'] = true; return item; } }); } $scope.selectedJewelFilter.type = preProductFilter["jewel"]["type"]["$in"]; } } if(preProductFilter && preProductFilter["watch"]){ if(preProductFilter["watch"]["indication"] && preProductFilter["watch"]["indication"]["$in"]){ $scope.selectedWatchFilter.timeIndication = preProductFilter["watch"]["indication"]["$in"]; } if(preProductFilter["watch"]["movement"] && preProductFilter["watch"]["movement"]["$in"]){ $scope.selectedWatchFilter.movement = preProductFilter["watch"]["movement"]["$in"]; } if(preProductFilter["watch"]["case"]){ if(preProductFilter["watch"]["case"]["color"]){ if($scope.selectedCategory == "JEWEL"){ $scope.commonColor.map(color=> { if($scope.configData[color.key]){ $scope.defaultFilters['jewelColor'] = true; } }); $scope.selectedJewelFilter.color = preProductFilter["watch"]["case"]["color"]["$in"]; }else{ $scope.commonColor.map(color=> { if($scope.configData[color.key]){ $scope.defaultFilters['watchCaseColor'] = true; } }); $scope.selectedWatchFilter.case.color = preProductFilter["watch"]["case"]["color"]["$in"]; } } if(preProductFilter["watch"]["case"]["material"]){ $scope.selectedWatchFilter.case.material = preProductFilter["watch"]["case"]["material"]["$in"]; } if(preProductFilter["watch"]["case"]["size"]){ $scope.selectedWatchFilter.case.size.min = preProductFilter["watch"]["case"]["size"]["$gte"]; $scope.selectedWatchFilter.case.size.max = preProductFilter["watch"]["case"]["size"]["$lte"]; } if(preProductFilter["watch"]["case"]["shape"]){ $scope.selectedWatchFilter.case.model = preProductFilter["watch"]["case"]["shape"]["$in"]; } if(preProductFilter["watch"]["case"]["waterproofLevel"]){ $scope.selectedWatchFilter.waterTightness.min = preProductFilter["watch"]["case"]["waterproofLevel"]["$gte"]; $scope.selectedWatchFilter.waterTightness.max = preProductFilter["watch"]["case"]["waterproofLevel"]["$lte"]; } } if(preProductFilter["watch"]["strap"]){ if(preProductFilter["watch"]["strap"]["model"] && preProductFilter["watch"]["strap"]["model"]["$in"]){ if($scope.selectedCategory == "WATCH"){ $scope.selectedWatchFilter.strap.type = preProductFilter["watch"]["strap"]["model"]["$in"]; }else{ $scope.selectedStrapFilter.type = preProductFilter["watch"]["strap"]["model"]["$in"]; } } if(preProductFilter["watch"]["strap"]["color"] && preProductFilter["watch"]["strap"]["color"]["$in"]){ if($scope.selectedCategory == "WATCH"){ $scope.commonColor.map(color=> { if($scope.configData[color.key]){ $scope.defaultFilters['watchStrapColor'] = true; } }); $scope.selectedWatchFilter.strap.color = preProductFilter["watch"]["strap"]["color"]["$in"]; }else{ $scope.commonColor.map(color=> { if($scope.configData[color.key]){ $scope.defaultFilters['strapColor'] = true; } }); $scope.selectedStrapFilter.color = preProductFilter["watch"]["strap"]["color"]["$in"]; } } if(preProductFilter["watch"]["strap"]["material"] && preProductFilter["watch"]["strap"]["material"]["$in"]){ if($scope.selectedCategory == "WATCH"){ $scope.selectedWatchFilter.strap.material = preProductFilter["watch"]["strap"]["material"]["$in"]; }else{ $scope.selectedStrapFilter.material = preProductFilter["watch"]["strap"]["material"]["$in"]; } } if(preProductFilter["watch"]["strap"]["width"] && preProductFilter["watch"]["strap"]["width"]["$gte"] && preProductFilter["watch"]["strap"]["width"]["$lte"]){ if($scope.selectedCategory == "WATCH"){ $scope.selectedWatchFilter.strap.width.min = preProductFilter["watch"]["strap"]["width"]["$gte"]; $scope.selectedWatchFilter.strap.width.max = preProductFilter["watch"]["strap"]["width"]["$lte"]; }else{ $scope.selectedStrapFilter.width.min = preProductFilter["watch"]["strap"]["width"]["$gte"]; $scope.selectedStrapFilter.width.max = preProductFilter["watch"]["strap"]["width"]["$lte"]; } } } if(preProductFilter["watch"]["glassMaterial"] && preProductFilter["watch"]["glassMaterial"]["$in"]){ $scope.selectedWatchFilter.glassType = preProductFilter["watch"]["glassMaterial"]["$in"]; } if(preProductFilter["watch"]["type"] && preProductFilter["watch"]["type"]["$in"]){ if($scope.configData.category && $scope.configData.category == "WATCH"){ if($scope.configData.wrist || $scope.configData.pocket || $scope.configData.nurse || $scope.configData.smartwatch){ $scope.defaultFilters['watchType'] = true; } } $scope.selectedWatchFilter.type = preProductFilter["watch"]["type"]["$in"]; } if(preProductFilter["watch"]["dial"]){ if(preProductFilter["watch"]["dial"]["index"] && preProductFilter["watch"]["dial"]["index"]["$in"]){ $scope.selectedWatchFilter.index = preProductFilter["watch"]["dial"]["index"]["$in"]; } if(preProductFilter["watch"]["dial"]["color"] && preProductFilter["watch"]["dial"]["color"]["$in"]){ $scope.selectedWatchFilter.dial.color = preProductFilter["watch"]["dial"]["color"]["$in"]; } } } if(preWatchParticularsFilter && preWatchParticularsFilter.length > 0){ $scope.selectedWatchFilter.particulars = preWatchParticularsFilter; } delete_cookie('isBackFromDetails'); delete_cookie('preShopFilter'); delete_cookie('preProductFilter'); delete_cookie('preOrderBy'); delete_cookie('preBrandFilter'); delete_cookie('preCollectionFilter'); delete_cookie('preWatchParticularsFilter'); } else { $scope.setConfigFilter = true; $scope.saleLabelStyle['background-color'] = $scope.configData.saleBgColor ? $scope.configData.saleBgColor : '#e1ddc3'; $scope.saleLabelStyle.color = $scope.configData.saleTextColor ? $scope.configData.saleTextColor : '#333333'; if($scope.configData.filterLayout == 'left' && $scope.device == 'desktop'){ $scope.showMoreFilters = true; } if ($scope.configData.hasStock) { shopFilter.hasStock = $scope.configData.hasStock; } // Check and set default sort functionality if ($scope.configData.sortBy && $scope.configData.sortBy != "none"){ $scope.orderBy['sort'] = {}; if ($scope.configData.sortBy === "priceAsc") { $scope.orderBy['sort'] = { price: "asc" }; } if ($scope.configData.sortBy === "priceDec") { $scope.orderBy['sort'] = { price: "desc" }; } if ($scope.configData.sortBy === "new") { $scope.orderBy['sort'] = { creationDate: "desc" }; } if ($scope.configData.sortBy === "lastAdded") { $scope.orderBy['sort'] = { dateAdded: "desc" }; } if ($scope.configData.sortBy === "productNumber") { $scope.orderBy['sort'] = { productNumber: "desc" }; } } if($scope.configData.category && $scope.configData.category == "WATCH"){ $scope.defaultFilters['category'] = true; if($scope.configData.wrist){ $scope.selectedWatchFilter.type.push('WRIST'); $scope.defaultFilters['watchType'] = true; } if($scope.configData.pocket){ $scope.selectedWatchFilter.type.push('POCKET'); $scope.defaultFilters['watchType'] = true; } if($scope.configData.nurse){ $scope.selectedWatchFilter.type.push('NURSE'); $scope.defaultFilters['watchType'] = true; } if($scope.configData.smartwatch){ $scope.selectedWatchFilter.type.push('SMARTWATCH'); $scope.defaultFilters['watchType'] = true; } // $scope.strapColors.map(color=> { // if($scope.configData[color.key]){ // $scope.selectedWatchFilter.strap.color.push(color.key); // } // }); $scope.commonColor.map(color=> { if($scope.configData[color.key]){ $scope.selectedWatchFilter.case.color.push(color.key); $scope.defaultFilters['watchCaseColor'] = true; } }); $scope.commonMaterial.map(material=> { if($scope.configData[material.value]){ $scope.selectedWatchFilter.strap.material.push(material.value); $scope.defaultFilters['strapMaterial'] = true; } }); if($scope.configData["minWaterProofLevel"] && parseInt($scope.configData["minWaterProofLevel"]) >= 0 && $scope.configData["maxWaterProofLevel"] && parseInt($scope.configData["maxWaterProofLevel"]) >= 2 && parseInt($scope.configData["minWaterProofLevel"]) <= parseInt($scope.configData["maxWaterProofLevel"])){ $scope.selectedWatchFilter.waterTightness.min = parseInt($scope.configData["minWaterProofLevel"]); $scope.selectedWatchFilter.waterTightness.max = parseInt($scope.configData["maxWaterProofLevel"]); $scope.defaultFilters['waterTightness'] = true; } // $scope.commonColor.map(color=> { // if($scope.configData[color.key]){ // $scope.selectedWatchFilter.dial.color.push(color.key); // } // }); } else if($scope.configData.category && $scope.configData.category == "STRAP"){ $scope.defaultFilters['category'] = true; $scope.commonColor.map(color=> { if($scope.configData[color.key]){ $scope.selectedStrapFilter.color.push(color.key); $scope.defaultFilters['strapColor'] = true; } }); $scope.commonMaterial.map(material=> { if($scope.configData[material.value]){ $scope.selectedWatchFilter.strap.material.push(material.value); $scope.defaultFilters['strapMaterial'] = true; } }); } else if($scope.configData.category && $scope.configData.category == "JEWEL"){ $scope.defaultFilters['category'] = true; $scope.commonColor.map(color=> { if($scope.configData[color.key]){ $scope.selectedJewelFilter.color.push(color.key); $scope.defaultFilters['jewelColor'] = true; } }); $scope.commonMaterial.map(color=> { if($scope.configData[color.value]){ $scope.selectedJewelFilter.material.push(color.value); $scope.defaultFilters['jewelMaterial'] = true; } }); } // Check for gender filter if ($scope.configData.gMen || $scope.configData.gLadies || $scope.configData.gBoy || $scope.configData.gGirl) { $scope.productFilter['gender'] = []; if ($scope.configData.gMen) { $scope.menFilter = true; $scope.productFilter['gender'].push({ "product.male": true, "product.kids": false }); $scope.defaultFilters['gender'] = true; } if ($scope.configData.gLadies) { $scope.ladiesFilter = true; $scope.productFilter['gender'].push({ "product.female": true, "product.kids": false }); $scope.defaultFilters['gender'] = true; } if ($scope.configData.gBoy) { $scope.boyFilter = true; $scope.productFilter['gender'].push({ "product.kids": true, "product.male": true }); $scope.defaultFilters['gender'] = true; } if ($scope.configData.gGirl) { $scope.girlFilter = true; $scope.productFilter['gender'].push({ "product.kids": true, "product.female": true }); $scope.defaultFilters['gender'] = true; } } // Check for collection filter if ($scope.collections.length > 0 && !$scope.configData.showAllCollection && $scope.configData.collectionList && $scope.configData.collectionList.trim() != "") { $scope.productFilter['collection'] = []; let collectionNameList = ($scope.configData.collectionList.toLowerCase()).split(","); $scope.collectionFilterIdWithNameSlug = {}; let filteredCollection = $scope.collections.filter(function(item){ if(collectionNameList.indexOf((item.name.toLowerCase()).trim()) > -1){ $scope.defaultFilters['collection'] = true; $scope.productFilter['collection'].push(item._id); $scope.collectionFilterIdWithNameSlug[item._id] = { name: item.name, nameSlug: item.nameSlug, selected: true }; } return item; }); } // Check for collection filter if ($scope.shopDetails && $scope.shopDetails.brands && $scope.shopDetails.brands.length > 0 && !$scope.configData.showAllBrands && $scope.configData.brandList && $scope.configData.brandList.trim() != "") { $scope.productFilter['brand'] = { '$in': [] }; let brandNameList = ($scope.configData.brandList.toLowerCase().trim()).split(","); brandNameList = brandNameList.map(Function.prototype.call, String.prototype.trim) let filteredCollection = $scope.shopDetails.brands.filter(function(item){ if(brandNameList.indexOf((item.name.toLowerCase()).trim()) > -1){ $scope.defaultFilters['brand'] = true; $scope.setFilterCount.brands = false; $scope.productFilter['brand']['$in'].push(item._id); $scope.brandFilterIdWithNameSlug[item._id] = { name: item && item.alias && item.alias !== "" ? item.alias : item && item.name ? item.name : item._id, nameSlug: item.nameSlug, selected: true }; } return item; }); } // Check for category filter if ($scope.configData.category && $scope.configData.category != "ALL") { $scope.selectedCategory = $scope.configData.category; $scope.setFilterCount.category = false; } // Check for discount filter if ($scope.configData.applyDiscount && $scope.configData.discountFilter == "discount") { shopFilter['discount'] = true; $scope.defaultFilters['discount'] = true; $scope.discountFilter = true; } // Check for bestseller filter if ($scope.configData.applyDiscount && $scope.configData.discountFilter == "bestseller") { shopFilter['isBestseller'] = true; $scope.defaultFilters['discount'] = true; $scope.bestsellerFilter = true; } // Check for bestseller filter if ($scope.configData.applyDiscount && $scope.configData.discountFilter == "featured") { shopFilter['isFeatured'] = true; $scope.defaultFilters['discount'] = true; $scope.isfeaturedFilter = true; } } if($scope.shopDetails.dropShippers && $scope.shopDetails.dropShippers.length > 0){ $scope.shopDetails.dropShippers.filter(shipper =>{ if(shipper.defaultShipper == true){ $scope.defaultShipper = true; $scope.companyIndex = 0; $scope.defaultCompanyId = shipper.companyId; $scope.defaultBrandId = shipper.brandId; $scope.shopFilter = {...$scope.shopFilter, ...shopFilter}; if (Object.keys($scope.brandFilterIdWithNameSlug).length && Object.keys($scope.brandFilterIdWithNameSlug).length > 0) { if($scope.brandFilterIdWithNameSlug[brandId]) { $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } }else{ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter,true, true, true); } } }); } if($scope.defaultShipper == false){ $scope.shopFilter = {...$scope.shopFilter, ...shopFilter}; $scope.fetchFilteredProducts(true, false, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; $scope.fetchFilteredProducts = function (reinitialFilter, isCallInternally, limit, shopfilter, productfilter, isReset = false, shopId = '', loadCounts = false) { $scope.limit = limit; $scope.loading = true; $scope.showAddcartModal = false; let jewelFilter = {}; let watchFilter = {}; let strapFilter = {}; if($scope.configData.filterLayout == 'left' && isCallInternally && $scope.device == 'desktop'){ setEventForAccordion(); } // Jewel color if ($scope.selectedJewelFilter.color && $scope.selectedJewelFilter.color.length > 0) { jewelFilter['color'] = { "$in": $scope.selectedJewelFilter.color }; $scope.setFilterCount.watch.case.color = false; } else { $scope.setFilterCount.watch.case.color = true; } // Jewel material if ($scope.selectedJewelFilter.material && $scope.selectedJewelFilter.material.length > 0) { jewelFilter['material'] = { "$in": $scope.selectedJewelFilter.material }; $scope.setFilterCount.jewel.material = false; } else { $scope.setFilterCount.jewel.material = true; } // Jewel filter to add into API end // Jewel Size if($scope.selectedJewelFilter.size && $scope.selectedJewelFilter.size.min && $scope.selectedJewelFilter.size.max && $scope.selectedJewelFilter.size.max > 1){ jewelFilter['size'] = { "$gte": $scope.selectedJewelFilter.size.min, "$lte": $scope.selectedJewelFilter.size.max }; } // Strap filter to add into API start // For strap type if ($scope.selectedStrapFilter.type && $scope.selectedStrapFilter.type.length > 0) { if (watchFilter['strap']) { watchFilter['strap']['model'] = { "$in": $scope.selectedStrapFilter.type }; } else { watchFilter['strap'] = {}; watchFilter['strap'] = { model: { "$in": $scope.selectedStrapFilter.type } }; } $scope.setFilterCount.strap.model = false; } else { $scope.setFilterCount.strap.model = true; } // For strap color if ($scope.selectedStrapFilter.color && $scope.selectedStrapFilter.color.length > 0) { if (watchFilter['strap']) { watchFilter['strap']['color'] = { "$in": $scope.selectedStrapFilter.color }; } else { watchFilter['strap'] = {}; watchFilter['strap'] = { color: { "$in": $scope.selectedStrapFilter.color } }; } $scope.setFilterCount.strap.color = false; } else { $scope.setFilterCount.strap.color = true; } // For strap material if ($scope.selectedStrapFilter.material && $scope.selectedStrapFilter.material.length > 0) { if (watchFilter['strap']) { watchFilter['strap']['material'] = { "$in": $scope.selectedStrapFilter.material }; } else { watchFilter['strap'] = {}; watchFilter['strap'] = { material: { "$in": $scope.selectedStrapFilter.material } }; } $scope.setFilterCount.strap.material = false; } else { $scope.setFilterCount.strap.material = true; } // For strap width if ($scope.selectedStrapFilter.width.min && $scope.selectedStrapFilter.width.max) { if (watchFilter['strap']) { watchFilter['strap']['width'] = { "$gte": $scope.selectedStrapFilter.width.min, "$lte": $scope.selectedStrapFilter.width.max }; } else { watchFilter['strap'] = {}; watchFilter['strap'] = { "$gte": $scope.selectedStrapFilter.width.min, "$lte": $scope.selectedStrapFilter.width.max }; } } // Strap filter to add into API end // Watch filter to add into API start // For particulars if ($scope.selectedWatchFilter.particulars && $scope.selectedWatchFilter.particulars.length > 0) { for(let i = 0; i < $scope.selectedWatchFilter.particulars.length; i++) { watchFilter[$scope.selectedWatchFilter.particulars[i]] = true; } $scope.setFilterCount.watch.dial.color = false; } else { $scope.setFilterCount.watch.dial.color = true; } // For time indication if ($scope.selectedWatchFilter.timeIndication && $scope.selectedWatchFilter.timeIndication.length > 0) { watchFilter['indication'] = { $in: $scope.selectedWatchFilter.timeIndication }; $scope.setFilterCount.watch.indication = false; } else { $scope.setFilterCount.watch.indication = true; } // For watch movement if ($scope.selectedWatchFilter.movement && $scope.selectedWatchFilter.movement.length > 0) { watchFilter['movement'] = { $in: $scope.selectedWatchFilter.movement }; $scope.setFilterCount.watch.movement = false; } else { $scope.setFilterCount.watch.movement = true; } // For watch type if ($scope.selectedWatchFilter.type && $scope.selectedWatchFilter.type.length > 0) { watchFilter['type'] = { $in: $scope.selectedWatchFilter.type }; } // For index if ($scope.selectedWatchFilter.index && $scope.selectedWatchFilter.index.length > 0) { if (watchFilter['dial']) { watchFilter['dial']['index'] = { "$in": $scope.selectedWatchFilter.index }; } else { watchFilter['dial'] = {}; watchFilter['dial'] = { index: { "$in": $scope.selectedWatchFilter.index } }; } $scope.setFilterCount.watch.dial.index = false; } else { $scope.setFilterCount.watch.dial.index = true; } // For watch strap width if ($scope.selectedWatchFilter.strap.width.min >= 0 && $scope.selectedWatchFilter.strap.width.max > 0) { if (watchFilter['strap']) { watchFilter['strap']['width'] = { "$gte": $scope.selectedWatchFilter.strap.width.min, "$lte": $scope.selectedWatchFilter.strap.width.max }; } else { watchFilter['strap'] = {}; watchFilter['strap'] = { width : {"$gte": $scope.selectedWatchFilter.strap.width.min, "$lte": $scope.selectedWatchFilter.strap.width.max }}; } } // For watch strap type if ($scope.selectedWatchFilter.strap.type && $scope.selectedWatchFilter.strap.type.length > 0) { if (watchFilter['strap']) { watchFilter['strap']['model'] = { "$in": $scope.selectedWatchFilter.strap.type }; } else { watchFilter['strap'] = {}; watchFilter['strap'] = { model: { "$in": $scope.selectedWatchFilter.strap.type } }; } $scope.setFilterCount.strap.model = false; } else { $scope.setFilterCount.strap.model = true; } // For watch glass material if ($scope.selectedWatchFilter.glassType && $scope.selectedWatchFilter.glassType.length > 0) { watchFilter['glassMaterial'] = { "$in": $scope.selectedWatchFilter.glassType }; } // For watch strap color if ($scope.selectedWatchFilter.strap.color && $scope.selectedWatchFilter.strap.color.length > 0) { if (watchFilter['strap']) { watchFilter['strap']['color'] = { "$in": $scope.selectedWatchFilter.strap.color }; } else { watchFilter['strap'] = {}; watchFilter['strap'] = { color: { "$in": $scope.selectedWatchFilter.strap.color } }; } $scope.setFilterCount.strap.model = false; } else { $scope.setFilterCount.strap.model = true; } // For watch strap material if ($scope.selectedWatchFilter.strap.material && $scope.selectedWatchFilter.strap.material.length > 0) { if (watchFilter['strap']) { watchFilter['strap']['material'] = { "$in": $scope.selectedWatchFilter.strap.material }; } else { watchFilter['strap'] = {}; watchFilter['strap'] = { material: { "$in": $scope.selectedWatchFilter.strap.material } }; } } // For watch case color if ($scope.selectedWatchFilter.case.color && $scope.selectedWatchFilter.case.color.length > 0) { if (watchFilter['case']) { watchFilter['case']['color'] = { "$in": $scope.selectedWatchFilter.case.color }; } else { watchFilter['case'] = {}; watchFilter['case'] = { color: { "$in": $scope.selectedWatchFilter.case.color } }; } $scope.setFilterCount.watch.case.color = false; } else { $scope.setFilterCount.watch.case.color = true; } // For watch case material if ($scope.selectedWatchFilter.case.material && $scope.selectedWatchFilter.case.material.length > 0) { if (watchFilter['case']) { watchFilter['case']['material'] = { "$in": $scope.selectedWatchFilter.case.material }; } else { watchFilter['case'] = {}; watchFilter['case'] = { material: { "$in": $scope.selectedWatchFilter.case.material } }; } $scope.setFilterCount.watch.case.material = false; } else { $scope.setFilterCount.watch.case.material = true; } // For watch case size if ($scope.selectedWatchFilter.case.size.min >= 0 && $scope.selectedWatchFilter.case.size.max > 0) { if (watchFilter['case']) { watchFilter['case']['size'] = { "$gte": $scope.selectedWatchFilter.case.size.min, "$lte": $scope.selectedWatchFilter.case.size.max }; } else { watchFilter['case'] = {}; watchFilter['case'] = { size: { "$gte": $scope.selectedWatchFilter.case.size.min, "$lte": $scope.selectedWatchFilter.case.size.max } }; } } // For watch case material if ($scope.selectedWatchFilter.case.model && $scope.selectedWatchFilter.case.model.length > 0) { if (watchFilter['case']) { watchFilter['case']['shape'] = { "$in": $scope.selectedWatchFilter.case.model }; } else { watchFilter['case'] = {}; watchFilter['case'] = { shape: { "$in": $scope.selectedWatchFilter.case.model } }; } $scope.setFilterCount.watch.case.shape = false; } else { $scope.setFilterCount.watch.case.shape = true; } // For watch water tightness if ($scope.selectedWatchFilter.waterTightness.min >= 0 && $scope.selectedWatchFilter.waterTightness.max > 0) { if (watchFilter['waterproofLevel']) { watchFilter['waterproofLevel'] = { "$gte": $scope.selectedWatchFilter.waterTightness.min, "$lte": $scope.selectedWatchFilter.waterTightness.max }; } else { watchFilter['waterproofLevel'] = {}; watchFilter['waterproofLevel'] = { "$gte": $scope.selectedWatchFilter.waterTightness.min, "$lte": $scope.selectedWatchFilter.waterTightness.max }; } } // For watch dial color if ($scope.selectedWatchFilter.dial.color && $scope.selectedWatchFilter.dial.color.length > 0) { if (watchFilter['dial']) { watchFilter['dial']['color'] = { "$in": $scope.selectedWatchFilter.dial.color }; } else { watchFilter['dial'] = {}; watchFilter['dial'] = { color: { "$in": $scope.selectedWatchFilter.dial.color } }; } $scope.setFilterCount.watch.features = false; } else { $scope.setFilterCount.watch.features = true; } if (!isCallInternally && !$scope.isBackFromDetails){ $scope.selectedJewelFilter.type = []; if($scope.configData.category == "JEWEL"){ var convertedArray = Object.keys($scope.configData).map(key => ({ key, value: $scope.configData[key] })); var filteredArray = convertedArray.filter(function(item){ if($scope.jewelFilter.type.indexOf(item.key) > -1 && item.value){ $scope.defaultFilters['jewelType'] = true; $scope.selectedJewelFilter.type.push(item.key); return item; } }); } } if ($scope.selectedJewelFilter.type && $scope.selectedJewelFilter.type.length > 0) { jewelFilter['type'] = { "$in": $scope.selectedJewelFilter.type }; $scope.setFilterCount.jewel.type = false; } else { $scope.setFilterCount.jewel.type = true; } $scope.checkJewelType($scope.selectedJewelFilter.type); if ($scope.selectedCategory && $scope.availableCategoryFilters.indexOf($scope.selectedCategory) > -1) { productfilter["category"] = { "$in": [$scope.selectedCategory.toUpperCase()] }; }else { delete productfilter["category"]; } if (Object.keys(jewelFilter).length > 0) { productfilter['jewel'] = jewelFilter; } else if(productfilter['jewel']){ delete productfilter['jewel']; } if (Object.keys(watchFilter).length > 0) { productfilter['watch'] = watchFilter; } else if(productfilter['watch']){ delete productfilter['watch']; } if (isReset) { $scope.isAnyFilterApplied = false; $scope.initializeVariables(); shopfilter = $scope.shopFilter; productfilter = $scope.productFilter; } if (reinitialFilter === true) { $scope.products = []; $scope.page = 0; $scope.offset = 0; $scope.pageNumber = -1; $scope.loadedProductsCount = 0; } else { $scope.page = Number($scope.page) + Number($scope.limit); } if (Object.keys(shopfilter).length > 4 || Object.keys(productfilter).length > 0) { $scope.isAnyFilterApplied = true; }else{ $scope.isFiltersSet = false; $scope.isAnyFilterApplied = false; } if(!$scope.shopDetails.showProducts){ $scope.shopFilter.inStock = false; } if(JSON.stringify($scope.collectionFilterIdWithNameSlug) !== JSON.stringify({})){ $scope.limit = 400; } setCookie('preShopFilter', JSON.stringify(shopfilter)); setCookie('preProductFilter', JSON.stringify(productfilter)); setCookie('preOrderBy', JSON.stringify($scope.orderBy)); setCookie('preBrandFilter', JSON.stringify($scope.brandFilterIdWithNameSlug)); setCookie('preCollectionFilter', JSON.stringify($scope.collectionFilterIdWithNameSlug)); setCookie('preWatchParticularsFilter', JSON.stringify($scope.selectedWatchFilter.particulars)); shopId = shopId == '' ? $rootScope.storeId : shopId; let URL = $rootScope.apiBasepath + "/api/shop/stock-and-price-products-from-shop?shopId=" + shopId + "&shopFilter=" + JSON.stringify(shopfilter) + "&productFilter=" + JSON.stringify(productfilter)+ "&limit="+$scope.limit+"&offset=" + $scope.offset; if (Object.keys($scope.orderBy).length > 0) { URL = URL + "&orderBy=" + JSON.stringify($scope.orderBy); } var params = { multiShops: [ ], dropShipper: [] } if($scope.shopDetails.multiShops && $scope.shopDetails.multiShops.length > 0){ for(let i = 0; i < $scope.shopDetails.multiShops.length; i++){ if($scope.shopDetails.multiShops[i] && $scope.shopDetails.multiShops[i]._id){ params.multiShops.push({ _id : $scope.shopDetails.multiShops[i]._id }); } } } if($scope.shopDetails.dropShippers && $scope.shopDetails.dropShippers.length > 0){ for(let i = 0; i < $scope.shopDetails.dropShippers.length; i++){ if($scope.shopDetails.dropShippers[i] && $scope.shopDetails.dropShippers[i].brandId && $scope.shopDetails.dropShippers[i].companyId){ if (Object.keys($scope.brandFilterIdWithNameSlug).length && Object.keys($scope.brandFilterIdWithNameSlug).length > 0) { if($scope.brandFilterIdWithNameSlug[$scope.shopDetails.dropShippers[i].brandId]) { params.dropShipper.push({ brandId : $scope.shopDetails.dropShippers[i].brandId, companyId : $scope.shopDetails.dropShippers[i].companyId }); } }else{ params.dropShipper.push({ brandId : $scope.shopDetails.dropShippers[i].brandId, companyId : $scope.shopDetails.dropShippers[i].companyId }); } } } } // && JSON.stringify($scope.collectionFilterIdWithNameSlug) === JSON.stringify({}) if(loadCounts && JSON.stringify($scope.collectionFilterIdWithNameSlug) === JSON.stringify({})){ $scope.shopIndex = 0; $scope.companyIndex = -1; $scope.getMultiShopProductCounts(shopfilter, productfilter, params); } $(".select-custom").removeClass("opened"); $http({ url: URL, method: "GET", headers : $rootScope.corsHeaders }) .then(function (response) { if($scope.configData.filterLayout == 'left' && $scope.device == 'desktop'){ setEventForAccordion(); $scope.showMoreFilters = true; } $scope.loading = false; const productResponse = response.data.products; let tempProduct = []; // $scope.totalProduct = productResponse.length; $scope.loadedProductsCount += productResponse.length; if((typeof(productResponse) == 'undefined' || (productResponse && productResponse.length == 0)) && $scope.shopDetails.multiShops && $scope.shopDetails.multiShops.length > 0 && $scope.shopIndex < $scope.shopDetails.multiShops.length){ $scope.productsCount.multiShops[$scope.shopIndex].productCount = 0; if($scope.loadedProductsCount == 0){ $scope.loadedProductsCount = 0; } $scope.loadMoreFunction(); return; } let displayProductLimit = 0; if($scope.configData.showAllProducts){ displayProductLimit = $scope.configData.productLimit; } if(!$scope.setScrollPos && !$scope.isBackFromDetails){ $scope.setScrollPos = true; let scrollHeight = $("body")[0].scrollHeight; let scrollPos = window.scrollY + window.innerHeight + 2; if(scrollHeight < scrollPos){ window.scrollTo(100,100) } } else if($scope.isBackFromDetails){ let scrollPos = getCookie('recentSrollPos'); let height = $("#customProductListId").height() + 3400; if(scrollPos && height > scrollPos){ delete_cookie('recentSrollPos'); setTimeout(() => { window.scrollTo(100,scrollPos); }, 1000); } } if($scope.configData.showAllProducts){ // if (productResponse.length > 24) { // for(let i = 0; i < productResponse.length; i += 24) { // for(let j = i; j < i + 24; j++) { // if (productResponse[j]) { // tempProduct.push(productResponse[j]); // } // } // $scope.products.push(tempProduct); // tempProduct = []; // } // } else { // for(let i = 0; i < productResponse.length; i++){ // tempProduct.push(productResponse[i]); // } // $scope.products.push(tempProduct); // } if(JSON.stringify($scope.collectionFilterIdWithNameSlug) !== JSON.stringify({})){ $scope.totalProduct += productResponse.length; } if(productResponse.length == 0 && $scope.loadedProductsCount == 0){ var myVar = setInterval(function(){ if($scope.productsCount && $scope.productsCount.multiShops && $scope.productsCount.multiShops.length == 0){ clearInterval(myVar); $scope.loadMoreFunction(); } }, 500); if($scope.productsCount && $scope.productsCount.multiShops && $scope.productsCount.multiShops.length == 0){ clearInterval(myVar); $scope.loadMoreFunction(); } } for(let i = 0; i < productResponse.length; i++){ var isExist = [] var isProductVariantExist = [] var variantCollection = productResponse[i].collections.filter(sp => sp.variantsCollection == true ); if($scope.products.length > 0){ isExist = $scope.products.filter(p => { return (p.filter( product => product._id == productResponse[i]._id)).length > 0; }) if(variantCollection.length > 0){ $scope.products.filter(p => { isProductVariantExist = p.filter( product => { var collection = product.collections.filter(collection => collection._id == variantCollection[0]._id ) if(collection.length > 0){ product['productOption'] = product['productOption'] ? ++product['productOption'] : 2; // $scope.totalProduct -= 1 } return collection.length > 0; }); }); } } if(isExist.length == 0 && isProductVariantExist.length == 0){ if(variantCollection.length > 0 && tempProduct.length > 0){ isProductVariantExist = tempProduct.filter( product => { var collection = product.collections.filter(collection => collection._id == variantCollection[0]._id ) if(collection.length > 0){ product['productOption'] = product['productOption'] ? ++product['productOption'] : 2; // $scope.totalProduct -= 1 } return collection.length > 0; }); } if(isProductVariantExist.length == 0){ tempProduct.push(productResponse[i]); } }else if(params.multiShops.length > 0 && isProductVariantExist == 0){ $scope.loadedProductsCount -= 1; // $scope.sepratedTotalCount.multiShop -= 1 } } if($scope.pageNumber > -1 && $scope.products[$scope.pageNumber].length < 32){ let diff = 32 - $scope.products[$scope.pageNumber].length; diff = tempProduct.length > diff ? diff : tempProduct.length; for(let i = 0; i < diff; i++){ $scope.products[$scope.pageNumber].push(tempProduct[i]); } let remainProduct = tempProduct.splice(diff); if(remainProduct.length > 0){ $scope.pageNumber ++; $scope.products[$scope.pageNumber] = remainProduct; } else { } }else if(tempProduct.length > 0){ $scope.pageNumber ++; $scope.products[$scope.pageNumber] = tempProduct; } } else { let displayProductLimit = parseInt($scope.configData.productLimit) < productResponse.length ? parseInt($scope.configData.productLimit) : productResponse.length; for(let i = 0; i < displayProductLimit; i++){ let isExist = [] if($scope.products.length > 0){ isExist = $scope.products.filter(p => { return (p.filter( product => product._id == productResponse[i]._id)).length > 0; }) } if(isExist.length == 0){ tempProduct.push(productResponse[i]); }else if(params.multiShops.length > 0){ $scope.loadedProductsCount -= 1; // $scope.totalProduct -= 1 // $scope.sepratedTotalCount.multiShop -= 1 } } $scope.products.push(tempProduct); } if($scope.totalProduct > 0 && productResponse.length == 0 && $scope.shopDetails && $scope.shopDetails.multiShops && $scope.shopIndex < $scope.shopDetails.multiShops.length){ $scope.loadMoreFunction(); } if(loadCounts && JSON.stringify($scope.collectionFilterIdWithNameSlug) != JSON.stringify({})){ var brandFilter = []; $scope.filters = response.data.filters; } // $scope.brandFilters = $scope.filters.brands; $scope.loadMore = ($scope.products.length > Number($scope.limit)) ? true : false; $(".select-custom").removeClass("opened"); setTimeout(() => { // $("#dm .product-label").css("background-color", data.config.saleBgColor); // $("#dm .product-label").css("color", data.config.saleTextColor); loadMainJs(); }, 2000); }, function (err) { // hulla.send('Internal server error.', 'danger'); console.log("error==>", err); }); }; $scope.fetchFilteredCompanyProducts = (companyId, brandId, shopfilter, productfilter, reinitialFilter, isReset = false, loadCounts= false) =>{ $scope.loading = true; $scope.showAddcartModal = false; let jewelFilter = {}; let watchFilter = {}; let strapFilter = {}; // Jewel filter to add into API start if($scope.configData.filterLayout == 'left' && !loadCounts && $scope.device == 'desktop'){ setEventForAccordion(); } // Jewel type if ($scope.selectedJewelFilter.type && $scope.selectedJewelFilter.type.length) { jewelFilter['type'] = { "$in": $scope.selectedJewelFilter.type }; } $scope.checkJewelType($scope.selectedJewelFilter.type); // Jewel Size if($scope.selectedJewelFilter.size && $scope.selectedJewelFilter.size.min && $scope.selectedJewelFilter.size.max && $scope.selectedJewelFilter.size.max > 1){ jewelFilter['size'] = { "$gte": $scope.selectedJewelFilter.size.min, "$lte": $scope.selectedJewelFilter.size.max }; } // Jewel color if ($scope.selectedJewelFilter.color && $scope.selectedJewelFilter.color.length) { watchFilter['case'] = { color: { "$in": $scope.selectedJewelFilter.color } }; } // Jewel material if ($scope.selectedJewelFilter.material && $scope.selectedJewelFilter.material.length) { jewelFilter['material'] = { "$in": $scope.selectedJewelFilter.material }; } // Jewel filter to add into API end // Strap filter to add into API start // For strap type if ($scope.selectedStrapFilter.type && $scope.selectedStrapFilter.type.length) { if (watchFilter['strap']) { watchFilter['strap']['model'] = { "$in": $scope.selectedStrapFilter.type }; } else { watchFilter['strap'] = {}; watchFilter['strap'] = { model: { "$in": $scope.selectedStrapFilter.type } }; } } // For strap color if ($scope.selectedStrapFilter.color && $scope.selectedStrapFilter.color.length) { if (watchFilter['strap']) { watchFilter['strap']['color'] = { "$in": $scope.selectedStrapFilter.color }; } else { watchFilter['strap'] = {}; watchFilter['strap'] = { color: { "$in": $scope.selectedStrapFilter.color } }; } } // For strap material if ($scope.selectedStrapFilter.material && $scope.selectedStrapFilter.material.length) { if (watchFilter['strap']) { watchFilter['strap']['material'] = { "$in": $scope.selectedStrapFilter.material }; } else { watchFilter['strap'] = {}; watchFilter['strap'] = { material: { "$in": $scope.selectedStrapFilter.material } }; } } // For strap width if ($scope.selectedStrapFilter.width.min && $scope.selectedStrapFilter.width.max) { if (watchFilter['strap']) { watchFilter['strap']['width'] = { "$gte": $scope.selectedStrapFilter.width.min, "$lte": $scope.selectedStrapFilter.width.max }; } else { watchFilter['strap'] = {}; watchFilter['strap'] = { width : {"$gte": $scope.selectedStrapFilter.width.min, "$lte": $scope.selectedStrapFilter.width.max }}; } } // Strap filter to add into API end // Watch filter to add into API start // For particulars if ($scope.selectedWatchFilter.particulars && $scope.selectedWatchFilter.particulars.length) { for(let i = 0; i < $scope.selectedWatchFilter.particulars.length; i++) { watchFilter[$scope.selectedWatchFilter.particulars[i]] = true; } } // For time indication if ($scope.selectedWatchFilter.timeIndication && $scope.selectedWatchFilter.timeIndication.length) { watchFilter['indication'] = { '$in': $scope.selectedWatchFilter.timeIndication }; } // For watch movement if ($scope.selectedWatchFilter.movement && $scope.selectedWatchFilter.movement.length > 0) { watchFilter['movement'] = { $in: $scope.selectedWatchFilter.movement }; } // For watch type if ($scope.selectedWatchFilter.type && $scope.selectedWatchFilter.type.length > 0) { watchFilter['type'] = { '$in': $scope.selectedWatchFilter.type }; } // For index if ($scope.selectedWatchFilter.index && $scope.selectedWatchFilter.index.length) { if (watchFilter['dial']) { watchFilter['dial']['index'] = { "$in": $scope.selectedWatchFilter.index }; } else { watchFilter['dial'] = {}; watchFilter['dial'] = { index: { "$in": $scope.selectedWatchFilter.index } }; } } // For watch strap width if ($scope.selectedWatchFilter.strap.width.min >= 0 && $scope.selectedWatchFilter.strap.width.max > 0) { if (watchFilter['strap']) { watchFilter['strap']['width'] = { "$gte": $scope.selectedWatchFilter.strap.width.min, "$lte": $scope.selectedWatchFilter.strap.width.max }; } else { watchFilter['strap'] = {}; watchFilter['strap'] = { "$gte": $scope.selectedWatchFilter.strap.width.min, "$lte": $scope.selectedWatchFilter.strap.width.max }; } } // For watch strap type if ($scope.selectedWatchFilter.strap.type && $scope.selectedWatchFilter.strap.type.length) { if (watchFilter['strap']) { watchFilter['strap']['model'] = { "$in": $scope.selectedWatchFilter.strap.type }; } else { watchFilter['strap'] = {}; watchFilter['strap'] = { model: { "$in": $scope.selectedWatchFilter.strap.type } }; } } // For watch glass material if ($scope.selectedWatchFilter.glassType && $scope.selectedWatchFilter.glassType.length) { watchFilter['glassMaterial'] = { "$in": $scope.selectedWatchFilter.glassType }; } // For watch strap color if ($scope.selectedWatchFilter.strap.color && $scope.selectedWatchFilter.strap.color.length) { if (watchFilter['strap']) { watchFilter['strap']['color'] = { "$in": $scope.selectedWatchFilter.strap.color }; } else { watchFilter['strap'] = {}; watchFilter['strap'] = { color: { "$in": $scope.selectedWatchFilter.strap.color } }; } } // For watch strap material if ($scope.selectedWatchFilter.strap.material && $scope.selectedWatchFilter.strap.material.length) { if (watchFilter['strap']) { watchFilter['strap']['material'] = { "$in": $scope.selectedWatchFilter.strap.material }; } else { watchFilter['strap'] = {}; watchFilter['strap'] = { material: { "$in": $scope.selectedWatchFilter.strap.material } }; } } // For watch case color if ($scope.selectedWatchFilter.case.color && $scope.selectedWatchFilter.case.color.length) { if (watchFilter['case']) { watchFilter['case']['color'] = { "$in": $scope.selectedWatchFilter.case.color }; } else { watchFilter['case'] = {}; watchFilter['case'] = { color: { "$in": $scope.selectedWatchFilter.case.color } }; } } // For watch case material if ($scope.selectedWatchFilter.case.material && $scope.selectedWatchFilter.case.material.length) { if (watchFilter['case']) { watchFilter['case']['material'] = { "$in": $scope.selectedWatchFilter.case.material }; } else { watchFilter['case'] = {}; watchFilter['case'] = { material: { "$in": $scope.selectedWatchFilter.case.material } }; } } // For watch case size if ($scope.selectedWatchFilter.case.size.min >= 0 && $scope.selectedWatchFilter.case.size.max > 0) { if (watchFilter['case']) { watchFilter['case']['size'] = { "$gte": $scope.selectedWatchFilter.case.size.min, "$lte": $scope.selectedWatchFilter.case.size.max }; } else { watchFilter['case'] = {}; watchFilter['case'] = { size: { "$gte": $scope.selectedWatchFilter.case.size.min, "$lte": $scope.selectedWatchFilter.case.size.max } }; } } // For watch case material if ($scope.selectedWatchFilter.case.model && $scope.selectedWatchFilter.case.model.length) { if (watchFilter['case']) { watchFilter['case']['shape'] = { "$in": $scope.selectedWatchFilter.case.model }; } else { watchFilter['case'] = {}; watchFilter['case'] = { shape: { "$in": $scope.selectedWatchFilter.case.model } }; } } // For watch water tightness if ($scope.selectedWatchFilter.waterTightness.min >= 0 && $scope.selectedWatchFilter.waterTightness.max > 0) { if (watchFilter['case']) { watchFilter['case']['waterproofLevel'] = { "$gte": $scope.selectedWatchFilter.waterTightness.min, "$lte": $scope.selectedWatchFilter.waterTightness.max }; } else { watchFilter['case'] = {}; watchFilter['case'] = { waterproofLevel: { "$gte": $scope.selectedWatchFilter.waterTightness.min, "$lte": $scope.selectedWatchFilter.waterTightness.max } }; } } // For watch dial color if ($scope.selectedWatchFilter.dial.color && $scope.selectedWatchFilter.dial.color.length) { if (watchFilter['dial']) { watchFilter['dial']['color'] = { "$in": $scope.selectedWatchFilter.dial.color }; } else { watchFilter['dial'] = {}; watchFilter['dial'] = { color: { "$in": $scope.selectedWatchFilter.dial.color } }; } } // Watch filter to add into API end if (Object.keys(jewelFilter).length > 0) { productfilter['jewel'] = jewelFilter; } if (Object.keys(watchFilter).length > 0) { productfilter['watch'] = watchFilter; } if ($scope.selectedCategory && $scope.availableCategoryFilters.indexOf($scope.selectedCategory) > -1) { productfilter["category"] = { "$in": [$scope.selectedCategory.toUpperCase()] }; } if (isReset) { $scope.isAnyFilterApplied = false; $scope.initializeVariables(); shopfilter = $scope.shopFilter; productfilter = $scope.productFilter; } if (reinitialFilter === true) { $scope.products = []; $scope.page = 0; $scope.offset = 0; $scope.pageNumber = -1; $scope.loadedProductsCount = 0; } else { $scope.page = Number($scope.page) + Number($scope.limit); } if (Object.keys(shopfilter).length > 4 || Object.keys(productfilter).length > 0) { $scope.isAnyFilterApplied = true; } else { $scope.isFiltersSet = false; $scope.isAnyFilterApplied = false; } if(!$scope.shopDetails.showProducts){ $scope.shopFilter.inStock = false; } var params = { multiShops: [ ], dropShipper: [] }; if($scope.defaultShipper == true){ params.dropShipper.push({ brandId : brandId, companyId : companyId }); } // if($scope.isBackFromDetails){ // shopFilter = {} // productFilter = {} // shopFilter = JSON.parse(getCookie('preShopFilter')); // productFilter = JSON.parse(getCookie('preProductFilter')); // } if(loadCounts){ $scope.shopIndex = 0; $scope.companyIndex = -1; $scope.getMultiShopProductCounts(shopfilter, productfilter, params); } setCookie('preShopFilter', JSON.stringify(shopfilter)); setCookie('preProductFilter', JSON.stringify(productfilter)); var URL = $rootScope.apiBasepath + "/api/v2/shop/stock-and-price-products-from-company-for-shop?companyId="+ companyId +"&brandId=" +brandId+ "&shopFilter=" + JSON.stringify(shopfilter) + "&productFilter=" + JSON.stringify(productfilter) + "&limit="+$scope.limit+"&offset=" + $scope.offset; if (Object.keys($scope.orderBy).length > 0) { URL = URL + "&orderBy=" + JSON.stringify($scope.orderBy); } $http({ url: URL, method: "GET", headers : $rootScope.corsHeaders }) .then(function (response) { if($scope.configData.filterLayout == 'left' && $scope.device == 'desktop'){ setEventForAccordion(); $scope.showMoreFilters = true; } $scope.loading = false; if(response.data.products.length == 0 && $scope.loadedProductsCount == 0){ $scope.totalProduct = 0; $scope.productsCount = undefined; if($scope.defaultShipper){ $scope.defaultShipper = false; $scope.defaultCompanyId = ''; $scope.defaultBrandId = ''; $scope.fetchFilteredProducts(true, false, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } } else if(response.data.products.length == 0 && $scope.loadedProductsCount != 0){ $scope.totalProduct = $scope.loadedProductsCount; $scope.productsCount = undefined; } const productResponse = response.data.products; let tempProduct = []; $scope.loadedProductsCount += productResponse.length; if($scope.isBackFromDetails){ let scrollPos = getCookie('recentSrollPos'); let height = $("#customProductListId").height(); if(height > scrollPos){ window.scrollTo(100,scrollPos); } } for(let i = 0; i < productResponse.length; i++){ let isExist = [] var isProductVariantExist = [] var variantCollection = productResponse[i].collections.filter(sp => sp.variantsCollection == true ); if($scope.products.length > 0){ // isExist = $scope.products.filter(p => { // var existProduct = p.filter( product => { // if(product._id == productResponse[i]._id){ // product['productOption'] = product['productOption'] ? ++product['productOption'] : 2; // return true; // } // }) // return (existProduct).length > 0; // }) if(variantCollection.length > 0){ $scope.products.filter(p => { isProductVariantExist = p.filter( product => { var collection = product.collections.filter(collection => collection._id == variantCollection[0]._id ) if(collection.length > 0){ product['productOption'] = product['productOption'] ? ++product['productOption'] : 2; } return collection.length > 0; }); }); } } var priceIncVAT = productResponse[i].product.suggestedRetailPrice * (1 + (productResponse[i].product.suggestedRetailPriceVat / 100)); if ((productResponse[i].sellingPrice * 1.5) > priceIncVAT){ productResponse[i].sellingPrice = productResponse[i].sellingPrice * 2.5 }else{ productResponse[i].sellingPrice = priceIncVAT } if(isExist.length == 0 && isProductVariantExist.length == 0){ if(variantCollection.length > 0 && tempProduct.length > 0){ isProductVariantExist = tempProduct.filter( product => { var collection = product.collections.filter(collection => collection._id == variantCollection[0]._id ) if(collection.length > 0){ product['productOption'] = product['productOption'] ? ++product['productOption'] : 2; } return collection.length > 0; }); } if(isProductVariantExist.length == 0){ tempProduct.push(productResponse[i]); } } // else if(params.multiShops.length > 0 && isProductVariantExist == 0){ // $scope.totalProduct -= 1 // $scope.sepratedTotalCount.dropshipper -= 1 // } } // $scope.products.push(tempProduct); if($scope.loadedProductsCount > 0 && $scope.pageNumber == -1){ $scope.pageNumber = 0 } if($scope.pageNumber > -1 && $scope.products[$scope.pageNumber] && $scope.products[$scope.pageNumber].length < 32){ let diff = 32 - $scope.products[$scope.pageNumber].length; diff = tempProduct.length > diff ? diff : tempProduct.length; for(let i = 0; i < diff; i++){ $scope.products[$scope.pageNumber].push(tempProduct[i]); } let remainProduct = tempProduct.splice(diff); if(remainProduct.length > 0){ $scope.pageNumber ++; $scope.products[$scope.pageNumber] = remainProduct; } else { } }else if(tempProduct.length > 0){ $scope.pageNumber ++; $scope.products[$scope.pageNumber] = tempProduct; } $scope.showCollectionFilter = false; $scope.loadMore = ($scope.products.length > Number($scope.limit)) ? true : false; }, function (err) { // hulla.send('Internal server error.', 'danger'); console.log("error==>", err); }); } $scope.loadMoreFunction = () => { if(!$scope.loading && $scope.productsCount){ let shopId = ''; let companyId = ''; let brandId = ''; let setPreviousShopId = false; if(!$scope.configData.showAllProducts){ if(parseInt($scope.configData.productLimit) > 0){ let loadedProductCount = 0; $scope.products.map(p => loadedProductCount += p.length); if(loadedProductCount == parseInt($scope.configData.productLimit)){ return; } else if(loadedProductCount > parseInt($scope.configData.productLimit)){ $scope.configData.productLimit = (parseInt($scope.configData.productLimit) - loadedProductCount).toString(); } else { return; } } } if($scope.defaultShipper == false && $scope.productsCount.multiShops && $scope.productsCount.multiShops.length > 0){ let shopProductCount = 0 if($scope.shopIndex > 0){ for(let i =0; i <= $scope.shopIndex; i++){ shopProductCount += $scope.productsCount.multiShops[i].productCount; } }else { shopProductCount = $scope.productsCount.multiShops[$scope.shopIndex].productCount; } let count = shopProductCount - $scope.loadedProductsCount; if( count < 1 && $scope.loadedProductsCount < $scope.sepratedTotalCount.multiShop){ $scope.shopIndex++; if(typeof($scope.productsCount.multiShops[$scope.shopIndex]) != 'undefined' && $scope.productsCount.multiShops[$scope.shopIndex]._id){ shopId = $scope.productsCount.multiShops[$scope.shopIndex]._id; } else { --$scope.shopIndex; shopId = $scope.productsCount.multiShops[$scope.shopIndex]._id; setPreviousShopId = true; } } else if($scope.productsCount.multiShops[$scope.shopIndex]._id) { shopId = $scope.productsCount.multiShops[$scope.shopIndex]._id; setPreviousShopId = true; } } if($scope.defaultShipper == false && $scope.sepratedTotalCount.multiShop <= $scope.loadedProductsCount){ if($scope.productsCount.dropShipper && $scope.productsCount.dropShipper.length > 0){ let count = $scope.companyIndex > -1 ? ($scope.sepratedTotalCount.multiShop + $scope.productsCount.dropShipper[$scope.companyIndex].productCount - $scope.loadedProductsCount) : 0; if(count < 1 && $scope.loadedProductsCount != $scope.totalProduct){ $scope.companyIndex++; // $scope.limit = 32; $scope.offset = 0; companyId = $scope.productsCount.dropShipper[$scope.companyIndex].companyId; brandId = $scope.productsCount.dropShipper[$scope.companyIndex].brandId; if (Object.keys($scope.brandFilterIdWithNameSlug).length && Object.keys($scope.brandFilterIdWithNameSlug).length > 0) { if($scope.brandFilterIdWithNameSlug[brandId]) { $scope.fetchFilteredCompanyProducts(companyId, brandId, $scope.shopFilter, $scope.productFilter, false); } }else{ $scope.fetchFilteredCompanyProducts(companyId, brandId, $scope.shopFilter, $scope.productFilter, false); } }else if(count > 0 && $scope.loadedProductsCount != $scope.totalProduct){ // $scope.limit += 32; $scope.offset += 1; companyId = $scope.productsCount.dropShipper[$scope.companyIndex].companyId; brandId = $scope.productsCount.dropShipper[$scope.companyIndex].brandId; if (Object.keys($scope.brandFilterIdWithNameSlug).length && Object.keys($scope.brandFilterIdWithNameSlug).length > 0) { if($scope.brandFilterIdWithNameSlug[brandId]) { $scope.fetchFilteredCompanyProducts(companyId, brandId, $scope.shopFilter, $scope.productFilter, false); } }else{ $scope.fetchFilteredCompanyProducts(companyId, brandId, $scope.shopFilter, $scope.productFilter, false); } } } }else if($scope.defaultShipper == true){ let count = $scope.companyIndex > -1 ? ($scope.productsCount.dropShipper[$scope.companyIndex].productCount - $scope.loadedProductsCount) : 0; if(count > 0 && $scope.loadedProductsCount != $scope.totalProduct){ // $scope.limit += 32; $scope.offset += 1; if (Object.keys($scope.brandFilterIdWithNameSlug).length && Object.keys($scope.brandFilterIdWithNameSlug).length > 0) { if($scope.brandFilterIdWithNameSlug[brandId]) { $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, false); } }else{ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, false); } } }else{ if(shopId != '' && !setPreviousShopId){ // $scope.limit = 32; $scope.offset = 0; } else { // $scope.limit += 32; $scope.offset += 1; } $scope.fetchFilteredProducts(false, true,$scope.limit, $scope.shopFilter, $scope.productFilter, false, shopId); } } else if(JSON.stringify($scope.collectionFilterIdWithNameSlug) !== JSON.stringify({}) && $scope.shopDetails.multiShops && $scope.shopDetails.multiShops.length > $scope.collectionShopIndex){ var shopId = $scope.shopDetails.multiShops[$scope.collectionShopIndex]._id; $scope.collectionShopIndex += 1; if(shopId){ $scope.fetchFilteredProducts(false, true,$scope.limit, $scope.shopFilter, $scope.productFilter, false, shopId); } } // $scope.loadMore = ($scope.products.length > Number($scope.limit)) ? true : false; }; // Function for get multiShop and drop shippers total products count $scope.getMultiShopProductCounts = function(shopFilter, productFilter, params){ $scope.totalProduct = 0; $http({ method: "GET", headers : $rootScope.corsHeaders, url: $rootScope.apiBasepath + "/api/v2/shop/multi-shop-product-count?currentShopId=" + $rootScope.storeId + "&shopFilter=" +JSON.stringify(shopFilter)+ "&productFilter=" + JSON.stringify(productFilter) + "&params=" + JSON.stringify(params) }) .then(function (response) { let temp = [{productCount: 0, _id: $rootScope.storeId}]; let updatedParam = [...temp, ...params.multiShops]; $scope.productsCount = JSON.parse(JSON.stringify(response.data.resProducts)); if($scope.productsCount.multiShops && $scope.productsCount.multiShops.length > 0){ if(updatedParam.length > $scope.productsCount.multiShops.length){ $scope.productsCount.multiShops = updatedParam; for(let i in $scope.productsCount.multiShops){ let shopData = response.data.resProducts.multiShops.filter(s => s._id == $scope.productsCount.multiShops[i]._id); if(shopData.length > 0){ $scope.productsCount.multiShops[i] = shopData[0]; } else { $scope.productsCount.multiShops[i].productCount = 0; } $scope.totalProduct += $scope.productsCount.multiShops[i].productCount ? $scope.productsCount.multiShops[i].productCount : 0; } } else { $scope.totalProduct += $scope.productsCount.multiShops[0].productCount; for(let i in $scope.productsCount.multiShops){ $scope.productsCount.multiShops[i].productCount = i < $scope.shopIndex ? 0 : $scope.productsCount.multiShops[i].productCount; } } } $scope.sepratedTotalCount.multiShop = $scope.totalProduct; if($scope.productsCount.dropShipper && $scope.productsCount.dropShipper.length > 0 && !$scope.bestsellerFilter && !$scope.discountFilter && !$scope.isfeaturedFilter){ for(let i in $scope.productsCount.dropShipper){ $scope.totalProduct += $scope.productsCount.dropShipper[i].productCount; $scope.sepratedTotalCount.dropshipper += $scope.productsCount.dropShipper[i].productCount; } } let currentShopProduct = $scope.productsCount.multiShops.filter(s => s._id == $rootScope.storeId); if($scope.sepratedTotalCount.multiShop < 30 && $scope.sepratedTotalCount.dropshipper && $scope.sepratedTotalCount.dropshipper > 0){ if($scope.sepratedTotalCount.multiShop == 0){ $scope.loading = false; } $scope.loadMoreFunction(); } else if(currentShopProduct.length== 0 || currentShopProduct[0].productCount == 0){ $scope.loading = false; $scope.loadMoreFunction(); } if(($scope.productsCount.multiShops && $scope.productsCount.multiShops.length > 0) || ($scope.productsCount.dropShipper && $scope.productsCount.dropShipper.length > 0)){ $scope.setMultiShopFilters($scope.productsCount); } }, function (err) { // hulla.send('Internal server error.', 'danger'); console.log("error==>", err); }); } $scope.priceFilter = function () { if (!$scope.shopFilter['price']) { $scope.shopFilter['price'] = {}; }; var searchParams = new URLSearchParams(window.location.search); if (($scope.minPrice === 0 || $scope.minPrice === undefined) && ($scope.maxPrice === 0 || $scope.maxPrice === undefined)) { delete $scope.shopFilter.price; } else { if ($scope.minPrice !== undefined && $scope.minPrice >= 0) { $scope.shopFilter.price['gte'] = $scope.minPrice; searchParams.set('priceLow', $scope.shopFilter.price['gte']); } else { if ($scope.shopFilter.price.gte) { delete $scope.shopFilter.price.gte; delete searchParams.delete('priceLow'); } } if ($scope.maxPrice !== undefined && $scope.maxPrice >= 1) { $scope.shopFilter.price['lte'] = $scope.maxPrice; searchParams.set('priceHigh', $scope.shopFilter.price['lte']); } else { if ($scope.shopFilter.price.lte) { delete $scope.shopFilter.price.lte; delete searchParams.delete('priceHigh'); } } } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; $scope.resetPriceFilter = function () { $scope.shopFilter.price['gte'] = 0; $scope.shopFilter.price['lte'] = 100000; if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; $scope.brandFilter = function (brandId, event, brandObj) { var searchParams = new URLSearchParams(window.location.search); // // $scope.brandFilterIdWithNameSlug = {}; if (event && event.target && event.target.checked) { if ($scope.brandFilterIdWithNameSlug[brandId]) { delete $scope.brandFilterIdWithNameSlug[brandId]; } else { $scope.brandFilterIdWithNameSlug[brandId] = { name: brandObj && brandObj.alias && brandObj.alias !== "" ? brandObj.alias : brandObj && brandObj.name ? brandObj.name : brandId, nameSlug: brandObj.nameSlug, selected: true }; } } if(event && event.target && !event.target.checked) { if ($scope.brandFilterIdWithNameSlug[brandId]) { delete $scope.brandFilterIdWithNameSlug[brandId]; } } $scope.productFilter['brand'] = { '$in': [] }; for (singleSelectedBrand in $scope.brandFilterIdWithNameSlug) { $scope.productFilter['brand']['$in'].push(singleSelectedBrand); $scope.setFilterCount.brands = false; } if($scope.productFilter['brand']['$in'].length == 0){ delete $scope.productFilter['brand']; $scope.setFilterCount.brands = true; } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; $scope.genderFilter = function (gender, flag) { $scope.productFilter['gender'] = []; let genderFilter = []; if (gender === "men" || $scope.menFilter === true) { $scope.menFilter = (flag === false && gender === "men" ? flag : true); if ($scope.menFilter === true) { $scope.productFilter['gender'].push({ "product.male": true, "product.kids": false }); genderFilter.push('men'); } } if (gender === "ladies" || $scope.ladiesFilter === true) { $scope.ladiesFilter = (flag === false && gender === "ladies" ? flag : true); if ($scope.ladiesFilter === true) { $scope.productFilter['gender'].push({ "product.female": true, "product.kids": false }); genderFilter.push('ladies'); } } if (gender === "boy" || $scope.boyFilter === true) { $scope.boyFilter = (flag === false && gender === "boy" ? flag : true); if ($scope.boyFilter === true) { $scope.productFilter['gender'].push({ "product.kids": true, "product.male": true }); genderFilter.push('boy'); } } if (gender === "girl" || $scope.girlFilter === true) { $scope.girlFilter = (flag === false && gender === "girl" ? flag : true); if ($scope.girlFilter === true) { $scope.productFilter['gender'].push({ "product.kids": true, "product.female": true }); genderFilter.push('girl'); } } $scope.setFilterCount.gender = false; if ($scope.productFilter.gender.length === 0) { delete $scope.productFilter.gender; $scope.setFilterCount.gender = true; } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; $scope.genderSmartFilter = function(gender,flag, categoryName) { $scope.productFilter['gender'] = []; let genderFilter = []; var searchParams = new URLSearchParams(window.location.search); searchParams.delete('gender'); if (gender === "men") { $scope.menFilter = (flag === false && gender === "men" ? flag : true); if ($scope.menFilter === true) { $scope.productFilter['gender'].push({ "product.male": true, "product.kids": false }); genderFilter.splice( genderFilter.indexOf('ladies'), 1 ); genderFilter.push('men'); } } if (gender === "ladies") { $scope.ladiesFilter = (flag === false && gender === "ladies" ? flag : true); if ($scope.ladiesFilter === true) { $scope.productFilter['gender'].push({ "product.female": true, "product.kids": false }); genderFilter.splice( genderFilter.indexOf('men'), 1 ); genderFilter.push('ladies'); } } if (categoryName) { $scope.selectedCategory = categoryName; } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } } $scope.disoc*ntFilter = function (filter, flag) { $scope.shopFilter['isBestseller'] = $scope.bestsellerFilter; $scope.shopFilter['discount'] = $scope.discountFilter; var searchParams = new URLSearchParams(window.location.search); if (filter === "bestseller") { $scope.shopFilter['isBestseller'] = flag; $scope.bestsellerFilter = flag; } if (filter === "discount") { $scope.shopFilter['discount'] = flag; $scope.discountFilter = flag; } if (filter === "isfeatured") { $scope.shopFilter['isFeatured'] = flag; $scope.isfeaturedFilter = flag; } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; $scope.removeSorting = function() { delete $scope.orderBy['sort']; if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; $scope.sortFilter = function (sortType) { $scope.orderBy['sort'] = {}; let sortTypeData; if (sortType === "priceAsc") { $scope.orderBy['sort'] = { price: "asc" }; sortTypeData = "asc"; } if (sortType === "priceDec") { $scope.orderBy['sort'] = { price: "desc" }; sortTypeData = "desc"; } if (sortType === "new") { $scope.orderBy['sort'] = { creationDate: "desc" }; sortTypeData = "desc"; } if (sortType === "lastAdded") { $scope.orderBy['sort'] = { dateAdded: "desc" }; sortTypeData = "desc"; } if (sortType === "productNumber") { $scope.orderBy['sort'] = { productNumber: "desc" }; sortTypeData = "desc"; } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; $scope.collectionFilter = function (id, event, collectionName, collectionNameSlug) { var searchParams = new URLSearchParams(window.location.search); $scope.collectionFilterIdWithNameSlug = {}; if (event.target.checked) { $scope.collectionFilterIdWithNameSlug[id] = { name: collectionName, nameSlug: collectionNameSlug, selected: true }; } else { // Check this id is exist into the collection array const isCollectionIdExists = $scope.collectionFilterIdWithNameSlug[id] ? true : false; if (isCollectionIdExists) { delete $scope.collectionFilterIdWithNameSlug[id]; }; } if(JSON.stringify($scope.collectionFilterIdWithNameSlug) !== JSON.stringify({})){ $scope.productFilter['collection'] = [] for (singleSelectedCollection in $scope.collectionFilterIdWithNameSlug) { $scope.productFilter['collection'].push(singleSelectedCollection); } }else { delete $scope.productFilter['collection']; } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; $scope.categoryFilter = function (categoryName, event) { var searchParams = new URLSearchParams(window.location.search); if (event.target.checked) { $scope.selectedCategory = categoryName; $scope.setFilterCount.category = false; } else { $scope.selectedCategory = ''; $scope.setFilterCount.category = true; } $scope.isFiltersSet = false; if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; // Jewel type filter $scope.jewelTypeFilter = function (type, event) { if (event.target.checked) { $scope.selectedJewelFilter.type.push(type); } else { $scope.selectedJewelFilter.type.splice($scope.selectedJewelFilter.type.indexOf(type), 1); } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; // Jewel color filter $scope.jewelColorFilter = function (color, event) { if (event.target.checked) { $scope.selectedJewelFilter.color.push(color); } else { $scope.selectedJewelFilter.color.splice($scope.selectedJewelFilter.color.indexOf(color), 1); } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; // Jewel material filter $scope.jewelMaterialFilter = function (material, event) { if (event.target.checked) { $scope.selectedJewelFilter.material.push(material); } else { $scope.selectedJewelFilter.material.splice($scope.selectedJewelFilter.material.indexOf(material), 1); } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; // Jewel size filter $scope.jewelSizeFilter = function (min, max){ if ((min === 0 || min === undefined) && (max === 0 || max === undefined)) { $scope.selectedJewelFilter.size = { min: 1, max: 1 }; } else { if (min !== undefined && min >= 1) { $scope.selectedJewelFilter.size.min = min; } else { $scope.selectedJewelFilter.size.min = 1; } if (max !== undefined && max >= 1) { $scope.selectedJewelFilter.size.max = max; } else { $scope.selectedJewelFilter.size.max = 1; } } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } } // Strap type filter $scope.strapTypeFilter = function (type, event) { if (event.target.checked) { $scope.selectedStrapFilter.type.push(type); } else { $scope.selectedStrapFilter.type.splice($scope.selectedStrapFilter.type.indexOf(type), 1); } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; // Strap color filter $scope.strapColorFilter = function (color, event) { if (event.target.checked) { $scope.selectedStrapFilter.color.push(color); } else { $scope.selectedStrapFilter.color.splice($scope.selectedStrapFilter.color.indexOf(color), 1); } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; // Strap material filter $scope.strapMaterialFilter = function (material, event) { if (event.target.checked) { $scope.selectedStrapFilter.material.push(material); } else { $scope.selectedStrapFilter.material.splice($scope.selectedStrapFilter.material.indexOf(material), 1); } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; // Strap width filter $scope.strapWidthFilter = function (min, max) { var searchParams = new URLSearchParams(window.location.search); if ((min === 0 || min === undefined) && (max === 0 || max === undefined)) { $scope.selectedStrapFilter.width = { min: 0, max: 0 }; searchParams.delete('strapMinWidth'); searchParams.delete('strapMaxWidth'); } else { if (min !== undefined && min >= 0) { searchParams.set('strapMinWidth', min); $scope.selectedStrapFilter.width.min = min; } else { $scope.selectedStrapFilter.width.min = 0; searchParams.delete('strapMinWidth'); } if (max !== undefined && max >= 1) { searchParams.set('strapMaxWidth', max); $scope.selectedStrapFilter.width.max = max; } else { $scope.selectedStrapFilter.width.max = 0; searchParams.delete('strapMaxWidth'); } } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; // Watch particulars filter $scope.watchParticularsFilter = function(particulars, event) { if (event.target.checked) { $scope.selectedWatchFilter.particulars.push(particulars); } else { $scope.selectedWatchFilter.particulars.splice($scope.selectedWatchFilter.particulars.indexOf(particulars), 1); } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; // Watch move filter $scope.watchMovementFilter = function(movement, event) { if (event.target.checked) { $scope.selectedWatchFilter.movement.push(movement); } else { $scope.selectedWatchFilter.movement.splice($scope.selectedWatchFilter.movement.indexOf(movement), 1); } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; // Watch particulars filter $scope.watchTimeIndicationFilter = function(indication, event) { if (event.target.checked) { $scope.selectedWatchFilter.timeIndication.push(indication); } else { $scope.selectedWatchFilter.timeIndication.splice($scope.selectedWatchFilter.timeIndication.indexOf(indication), 1); } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; // Watch index filter $scope.watchIndexFilter = function(index, event) { if (event.target.checked) { $scope.selectedWatchFilter.index.push(index); } else { $scope.selectedWatchFilter.index.splice($scope.selectedWatchFilter.index.indexOf(index), 1); } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; // Watch strap width filter $scope.watchStrapWidthFilter = function (min, max) { var searchParams = new URLSearchParams(window.location.search); if ((min === 0 || min === undefined) && (max === 0 || max === undefined)) { $scope.selectedWatchFilter.strap.width = { min: 0, max: 0 }; searchParams.delete('watchStrapMinWidth'); searchParams.delete('watchStrapMaxWidth'); } else { if (min !== undefined && min >= 0) { searchParams.set('watchStrapMinWidth', min); $scope.selectedWatchFilter.strap.width.min = min; } else { $scope.selectedWatchFilter.strap.width.min = 0; searchParams.delete('watchStrapMinWidth'); } if (max !== undefined && max >= 1) { searchParams.set('watchStrapMaxWidth', max); $scope.selectedWatchFilter.strap.width.max = max; } else { $scope.selectedWatchFilter.strap.width.max = 0; searchParams.delete('watchStrapMaxWidth'); } } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; // Watch strap type filter $scope.watchStrapTypeFilter = function (type, event) { if (event.target.checked) { $scope.selectedWatchFilter.strap.type.push(type); } else { $scope.selectedWatchFilter.strap.type.splice($scope.selectedWatchFilter.strap.type.indexOf(type), 1); } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; // Watch glass type filter $scope.watchGlassTypeFilter = function (type, event) { if (event.target.checked) { $scope.selectedWatchFilter.glassType.push(type); } else { $scope.selectedWatchFilter.glassType.splice($scope.selectedWatchFilter.glassType.indexOf(type), 1); } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; // Watch strap color filter $scope.watchStrapColorFilter = function (color, event) { if (event.target.checked) { $scope.selectedWatchFilter.strap.color.push(color); } else { $scope.selectedWatchFilter.strap.color.splice($scope.selectedWatchFilter.strap.color.indexOf(color), 1); } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; // Watch strap material filter $scope.watchStrapMaterialFilter = function (material, event) { if (event.target.checked) { $scope.selectedWatchFilter.strap.material.push(material); } else { $scope.selectedWatchFilter.strap.material.splice($scope.selectedWatchFilter.strap.material.indexOf(material), 1); } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; // Watch case color filter $scope.watchCaseColorFilter = function (color, event) { if (event.target.checked) { $scope.selectedWatchFilter.case.color.push(color); } else { $scope.selectedWatchFilter.case.color.splice($scope.selectedWatchFilter.case.color.indexOf(color), 1); } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; // Watch case material filter $scope.watchCaseMaterialFilter = function (material, event) { if (event.target.checked) { $scope.selectedWatchFilter.case.material.push(material); } else { $scope.selectedWatchFilter.case.material.splice($scope.selectedWatchFilter.case.material.indexOf(material), 1); } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; // Watch case width filter $scope.watchCaseSizeFilter = function (min, max) { var searchParams = new URLSearchParams(window.location.search); if ((min === 0 || min === undefined) && (max === 0 || max === undefined)) { $scope.selectedWatchFilter.case.size = { min: 0, max: 0 }; searchParams.delete('watchCaseMinSize'); searchParams.delete('watchCaseMaxSize'); } else { if (min !== undefined && min >= 0) { searchParams.set('watchCaseMinSize', min); $scope.selectedWatchFilter.case.size.min = min; } else { $scope.selectedWatchFilter.case.size.min = 0; searchParams.delete('watchCaseMinSize'); } if (max !== undefined && max >= 1) { searchParams.set('watchCaseMaxSize', max); $scope.selectedWatchFilter.case.size.max = max; } else { $scope.selectedWatchFilter.case.size.max = 0; searchParams.delete('watchCaseMaxSize'); } } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; // Watch case model filter $scope.watchCaseModelFilter = function (model, event) { if (event.target.checked) { $scope.selectedWatchFilter.case.model.push(model); } else { $scope.selectedWatchFilter.case.model.splice($scope.selectedWatchFilter.case.model.indexOf(model), 1); } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; // Watch dial color filter $scope.watchDialColorFilter = function (color, event) { if (event.target.checked) { $scope.selectedWatchFilter.dial.color.push(color); } else { $scope.selectedWatchFilter.dial.color.splice($scope.selectedWatchFilter.dial.color.indexOf(color), 1); } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; // Watch water tightness filter $scope.watchWaterTightnessFilter = function (min, max) { var searchParams = new URLSearchParams(window.location.search); if ((min === 0 || min === undefined) && (max === 0 || max === undefined)) { $scope.selectedWatchFilter.waterTightness = { min: 0, max: 0 }; searchParams.delete('watchWaterMinTightness'); searchParams.delete('watchWaterMaxTightness'); } else { if (min !== undefined && min >= 0) { searchParams.set('watchWaterMinTightness', min); $scope.selectedWatchFilter.waterTightness.min = min; } else { $scope.selectedWatchFilter.waterTightness.min = 0; searchParams.delete('watchWaterMinTightness'); } if (max !== undefined && max >= 1) { searchParams.set('watchWaterMaxTightness', max); $scope.selectedWatchFilter.waterTightness.max = max; } else { $scope.selectedWatchFilter.waterTightness.max = 0; searchParams.delete('watchWaterMaxTightness'); } } if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, false, '', true); } }; // Remove all filters $scope.removeAllFilters = function () { $scope.isFiltersSet = false; if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, true, $scope.limit, $scope.shopFilter, $scope.productFilter, true, '', true); } } // Function for reset selected filters $scope.resetFilters = function(){ $scope.isFiltersSet = false; if($scope.defaultShipper == true){ $scope.fetchFilteredCompanyProducts($scope.defaultCompanyId, $scope.defaultBrandId, $scope.shopFilter, $scope.productFilter, true, true, true); } else { $scope.fetchFilteredProducts(true, false, $scope.limit, $scope.shopFilter, $scope.productFilter, true, '', true); } } // Add to cart $scope.addToCart = function (productId, fromModal = false, otherDetails = {}) { const selectedLanguage = localStorage.getItem('selectedLanguage'); if($scope.cartItems.length > 0){ var cart = $scope.cartItems.filter(c => c.product == productId); if(cart.length > 0){ hulla.send(productExistCart[selectedLanguage], 'danger'); return; } } $scope.ajaxLoadProduct = true; const cartSuccessMsg = { en: { message: 'New item added into cart.' }, nl: { message: 'Nieuw item toegevoegd aan winkelwagen.' }, de: { message: 'Neuer Artikel in den Warenkorb gelegt.' }, fr: { message: 'Nouvel article ajouté au panier.' }, es: { message: 'Nuevo artículo agregado al carrito.' } } const token = localStorage.getItem('customer'); var reqData = { method: "POST", url: $rootScope.apiBasepath + "/api/customer/cart/" + $rootScope.storeId, data: { product: productId, quantity: fromModal ? Number($("#product-quantity").val()) ? Number($("#product-quantity").val()) : 1 : 1, sessionId : localStorage.getItem('SessionId') }, headers : $rootScope.corsHeaders }; // Update request data for other shop and drop shipper product if(otherDetails && otherDetails._id && otherDetails._id != $rootScope.storeId){ var isFrom = "shipper"; if($scope.productsCount.multiShops && $scope.productsCount.multiShops.length > 0){ for(let i in $scope.productsCount.multiShops){ if(otherDetails._id == $scope.productsCount.multiShops[i]._id){ isFrom = 'shop'; } } } reqData = { method: "POST", url: $rootScope.apiBasepath + "/api/customer/cart/" + $rootScope.storeId, data: { product: productId, quantity: fromModal ? Number($("#product-quantity").val()) ? Number($("#product-quantity").val()) : 1 : 1, sessionId : localStorage.getItem('SessionId'), isFrom : isFrom, details : { _id : otherDetails._id, name : otherDetails.name, nameSlug : otherDetails.nameSlug } }, headers : $rootScope.corsHeaders }; } if (token && token !== "") { reqData['headers'] = Object.assign($rootScope.corsHeaders, {"x-authorization": token ? token : ''}); } $http(reqData) .then(function (response) { $scope.cartItems.push({ product : reqData.data.product, quantity : reqData.data.quantity }); $scope.ajaxLoadProduct = false; hulla.send(cartSuccessMsg[selectedLanguage].message, 'success'); var setCount = parseInt($('.prismaStoreCart .cartItemsCount').html()); updateCartTotal(setCount + reqData.data.quantity); }, function (err) { $scope.ajaxLoadProduct = false; console.log("error==>", err); // if(err.data && err.data.message){ // hulla.send(err.data.message, 'danger'); // } }); }; // Set dynamic href for product details page $scope.setProductDetailHref = function(product){ var isFrom = ""; if($scope.productsCount && $scope.productsCount.multiShops && $scope.productsCount.multiShops.length > 0){ for(let i in $scope.productsCount.multiShops){ if(product.otherDetails._id == $scope.productsCount.multiShops[i]._id && $rootScope.storeId != product.otherDetails._id){ isFrom = 'shop'; } } } if($scope.productsCount && $scope.productsCount.dropShipper && $scope.productsCount.dropShipper.length > 0){ for(let i in $scope.productsCount.dropShipper){ if(product.otherDetails._id == $scope.productsCount.dropShipper[i]._id || (product.product.brand && product.product.brand._id == $scope.productsCount.dropShipper[i].brandId && $rootScope.storeId != product.otherDetails._id)){ isFrom = 'shipper'; } } } if(JSON.stringify($scope.collectionFilterIdWithNameSlug) !== JSON.stringify({}) && $scope.shopDetails.multiShops && $scope.shopDetails.multiShops.length > 0){ for(let i in $scope.shopDetails.multiShops){ if(product.otherDetails._id == $scope.shopDetails.multiShops[i]._id && $rootScope.storeId != product.otherDetails._id){ isFrom = 'shop'; } } } if( isFrom == "shop" ){ return "product-details?name=" + product.product.nl.nameSlug + "&msId=" + product.otherDetails._id; }else if( isFrom == "shipper"){ return "product-details?name=" + product.product.nl.nameSlug + "&scId=" + product.otherDetails._id; }else if($scope.isNavDetailsExist.length > 0 && ((product.shopProduct.stock - product.shopProduct.reservedQuantity) > 0)){ return "details/" + product.product.nl.nameSlug; }else{ return "product-details?name=" + product.product.nl.nameSlug; } } $scope.setMinHeightWithLeft = function(){ return $('.left-position-filter').height() + 'px'; } // set multi shop product filter $scope.setMultiShopFilters = function(obj){ let tempObject = {} let oldFiltersData = $scope.filters ? $scope.filters : []; let isOldFilterSet = $scope.filters ? true : false; let multiShopData = JSON.parse(JSON.stringify(obj.multiShops)); multiShopData = multiShopData.filter(o => typeof(o.filters) != 'undefined'); let objects = multiShopData.map(o => { delete o.filters['_id']; return o.filters; }); obj.dropShipper.map(o => { let brand = $scope.shopDetails.brands.filter(brand => brand._id == o.brandId); if(brand.length > 0){ o.filters['brands'] = {}; o.filters['brands'][brand[0]._id] = o.productCount; } delete o.filters['_id']; objects.push(o.filters); }); let objIndex = 0; if($scope.isAnyFilterApplied && isOldFilterSet){ tempObject = $scope.filters; } else { tempObject = objects[objIndex]; objIndex++; } let watchFeatures = ['hasDateFunction', 'hasLightFunction','hasSwissMovement','isAntiAllergy','isNickelFree', 'waterproofLevel']; let Length = objects.length; if(Length > 1){ for (let key1 of Object.keys(tempObject)) { if(typeof(tempObject[key1]) == 'object' && ($scope.setFilterCount[key1] || !isOldFilterSet)){ if(key1 == 'brands'){ for(let i =objIndex; i < Length; i++){ if(typeof(objects[i][key1]) != 'undefined'){ for(let key2 of Object.keys(objects[i][key1])){ tempObject[key1][key2] = ($scope.isAnyFilterApplied && isOldFilterSet) ? 0 : tempObject[key1][key2] if(typeof(tempObject[key1][key2]) == 'undefined'){ tempObject[key1][key2] = objects[i][key1][key2] } else { tempObject[key1][key2] += objects[i][key1][key2] } } } } } else if(key1 != '_id'){ for (let key2 of Object.keys(tempObject[key1])) { if(typeof(tempObject[key1][key2]) == 'object' && ($scope.setFilterCount[key1][key2] || !isOldFilterSet)){ for (let key3 of Object.keys(tempObject[key1][key2])) { if(typeof(tempObject[key1][key2][key3]) == 'object'){ for (let key4 of Object.keys(tempObject[key1][key2][key3])) { tempObject[key1][key2][key3][key4] = ($scope.isAnyFilterApplied && isOldFilterSet) ? 0 : tempObject[key1][key2][key3][key4] if(typeof(tempObject[key1][key2][key3][key4]) != 'object'){ for(let i = objIndex; i < Length; i++){ tempObject[key1][key2][key3][key4] += objects[i][key1][key2][key3][key4] } } } } else{ tempObject[key1][key2][key3] = ($scope.isAnyFilterApplied && isOldFilterSet) ? 0 : tempObject[key1][key2][key3] for(let i = objIndex; i < Length; i++){ tempObject[key1][key2][key3] += objects[i][key1][key2][key3] } } } } else if($scope.setFilterCount[key1][key2] || !isOldFilterSet || (watchFeatures.indexOf(key2) > -1 && $scope.setFilterCount[key1]['features'])){ tempObject[key1][key2] = ($scope.isAnyFilterApplied && isOldFilterSet) ? 0 : tempObject[key1][key2] for(let i = objIndex; i < Length; i++){ tempObject[key1][key2] += objects[i][key1][key2] } } else{ tempObject[key1][key2] = oldFiltersData[key1][key2] } } } } else if(key1 != '_id' && ($scope.setFilterCount[key1] || !isOldFilterSet)){ for(let i = objIndex; i < Length; i++){ tempObject[key1] += objects[i][key1] } } else { tempObject[key1] = oldFiltersData[key1] } } } else { } $scope.filters = tempObject; $scope.brandFilters = $scope.filters.brands; } $scope.getMultiShopBrandList = function(index){ $http({ method: "GET", headers : $rootScope.corsHeaders, url: $rootScope.apiBasepath + "/api/v2/shop/get-brands?shopId=" + $scope.shopDetails.multiShops[index]._id }) .then(function (response) { if(response && response.data && response.data.data && response.data.data.length > 0){ var brandList = response.data.data; brandList.filter(b => { var brand = $scope.shopDetails.brands.filter(b1 => b1._id == b._id); if(brand.length == 0){ $scope.shopDetails.brands.push(b); } }); $scope.shopDetails.brands.sort((a,b) => { let a_name = a.alias && a.alias!== "" ? a.alias : a.name; let b_name = b.alias && b.alias!== "" ? b.alias : b.name; return (a_name > b_name) ? 1 : ((b_name > a_name) ? -1 : 0); }); $scope.fetchedBrandList = true; if($scope.fetchedShopDetails && $scope.fetchedCollections && $scope.fetchedBrandList){ $scope.setFilters(); } } }, function (err) { $scope.fetchedBrandList = true; if($scope.fetchedShopDetails && $scope.fetchedCollections && $scope.fetchedBrandList){ $scope.setFilters(); } // hulla.send('Internal server error.', 'danger'); console.log("error==>", err); }); } $scope.toggleShowMore = function(value){ $scope.showMoreFilters = value; } $scope.checkJewelType = function(type){ var ringTypes= ["RING", "SEAL_RING", "COMBINATION_RING", "RING_WITH_PEARL","RING_WITH_GEM","CHOKER", "NECKLACE", "TENNIS_NECKLACE", "BRACELET", "TENNIS_BRACELET", "SLAVE_BRACELET"]; var allowedTypes = type.filter(t => { return ringTypes.includes(t); }); $scope.showJewelSizeFilter = allowedTypes.length > 0 && $scope.selectedCategory == 'JEWEL'; } $scope.isCustomFilterSelected = function(){ var element = $(".easy-to-remove-filter:not(.ng-hide):not(.filter-label)"); if( element && element.length == 0){ return true; } else { return false; } } $scope.showLog = function(value){ console.log(value); } $scope.toggleAccordion = function(event){ if(event && event.target && $(event.target).hasClass('accordion')){ event.target.classList.toggle("active"); var panel = event.target.nextElementSibling; if (panel.style.display === "block") { panel.style.display = "none"; } else { panel.style.display = "block"; } } else { event.preventDefault(); $(".select-custom").removeClass("opened"); $(event.target).closest(".select-custom").toggleClass("opened"); } } // Function for fetch thumbnail $scope.getThumbnailUrl = function(url){ var index = url.indexOf('/'); var folder = url.substring(0, index + 1); var fileName = url.replace(folder, ''); return folder + 'prismathumbnail-' + fileName; } // Fetch shop details $http({ method: "GET", headers : $rootScope.corsHeaders, url: $rootScope.apiBasepath + "/api/v2/website/shop/" + $rootScope.storeId + "/details" }) .then(function (response) { $scope.shopDetails = response.data.shop; $scope.shopDetails.brands.sort((a,b) => { let a_name = a.alias && a.alias!== "" ? a.alias : a.name; let b_name = b.alias && b.alias!== "" ? b.alias : b.name; return (a_name > b_name) ? 1 : ((b_name > a_name) ? -1 : 0); }); $scope.fetchedShopDetails = true; if ($scope.shopDetails && !$scope.shopDetails.isPublished) { window.location.href = "https://prismanote.com/home"; } if($scope.shopDetails.multiShops && $scope.shopDetails.multiShops.length > 0){ $scope.getMultiShopBrandList(0); } else { $scope.fetchedBrandList = true; } // Set shop details into localStorage localStorage.removeItem("gjs-css"); localStorage.removeItem("gjs-styles"); localStorage.removeItem("gjs-components"); localStorage.removeItem("gjs-html"); localStorage.setItem('shopDetails', JSON.stringify($scope.shopDetails)); localStorage.setItem('websiteName', websiteName); $rootScope.selectedLanguage = localStorage.getItem('selectedLanguage') ? localStorage.getItem('selectedLanguage') : 'nl'; var languageList = ['de','en','es','nl','fr']; $rootScope.selectedLanguage = languageList.includes($rootScope.selectedLanguage.toLowerCase()) ? $rootScope.selectedLanguage.toLowerCase() : 'nl'; if($scope.fetchedCollections && !$scope.setConfigFilter && $scope.configData.productLimit && $scope.fetchedBrandList){ $scope.setFilters(); } // && (!$scope.shopDetails.multiShops ||($scope.shopDetails.multiShops && $scope.shopDetails.multiShops.length == 0) // $scope.fetchFilteredProducts(true, $scope.limit, $scope.shopFilter, $scope.productFilter); // Filter using url params end }, function (err) { // hulla.send('Internal server error.', 'danger'); console.log("error==>", err); }); // Fetch collections from shop which is available for shop $http({ method: "GET", headers : $rootScope.corsHeaders, url: $rootScope.apiBasepath + "/api/website/collection/" + $rootScope.storeId + "?language=" + localStorage.getItem('selectedLanguage') }) .then(function (response) { $scope.collections = response.data && response.data.collections ? response.data.collections : []; $scope.fetchedCollections = true; $scope.showCollectionFilter = $scope.collections.length > 0 ? true : false; if($scope.fetchedShopDetails && !$scope.setConfigFilter && $scope.configData.productLimit && $scope.fetchedBrandList){ $scope.setFilters(); } }, function (err) { // hulla.send('Internal server error.', 'danger'); console.log("error==>", err); }); const token = localStorage.getItem('customer'); const fetchCartReqData = { method: "GET", url: $rootScope.apiBasepath + "/api/customer/cart/" + $rootScope.storeId, headers : $rootScope.corsHeaders, params : {sessionId : localStorage.getItem('SessionId')} }; if (token && token !== "") { fetchCartReqData['headers'] = Object.assign($rootScope.corsHeaders, {"x-authorization": token ? token : ''}); } $http(fetchCartReqData) .then(function (response) { $scope.cartItems = response.data.result.cart; $scope.totalCartItems = 0; $scope.cartItems.forEach(function(product) { $scope.totalCartItems += product.quantity ; }); $('.prismaStoreCart .cartItemsCount').text($scope.totalCartItems); }) // $scope.loadMoreFunction = () => { // $scope.limit += 1; // $scope.loadMore = ($scope.products.length > Number($scope.limit)) ? true : false; // }; }) app.filter('capitalize', function() { return function(input, product) { // return (angular.isString(input) && input.length > 0) ? input.charAt(0).toUpperCase() + input.substr(1).toLowerCase() : input; var splitStr = input.toLowerCase().split(' '); var brandName = product && product.brand && product.brand.name ? product.brand.name.toLowerCase().split(' ') : []; var originalStr = input.split(' '); for (var i = 0; i < splitStr.length; i++) { if(/\d/.test(splitStr[i])){ splitStr[i] = splitStr[i].toUpperCase(); }else { if(originalStr[i] == splitStr[i].toUpperCase() && brandName.includes(splitStr[i])){ splitStr[i] = originalStr[i]; }else{ splitStr[i] = splitStr[i].charAt(0).toUpperCase() + splitStr[i].substring(1); } } } return splitStr.join(' '); } });

- {[{product.shopProduct.discountOnPercentage ? '':'€'}]}{[{product.shopProduct.discount}]}{[{product.shopProduct.discountOnPercentage ? '%':''}]} In stock Bestseller Sale

{[{product.product[selectedLanguage].name | capitalize: product.product | limitTo: productTitleLength }]}{[{product.product[selectedLanguage].name.length > productTitleLength ? '...' : ''}]} {[{product.product[selectedLanguage].name | capitalize: product.product | limitTo: productTitleLength }]}{[{product.product[selectedLanguage].name.length > productTitleLength ? '...' : ''}]}

{[{ showTranslations['NOT_YET_IN_STOCK'] }]} {[{ showTranslations['stock-at-shop'] }]}

{[{product.productOption }]} {[{ selectedLanguage == 'nl' ? 'Maten' : showTranslations['OPTIONS'] }]} {[{ showTranslations['stock-at-shop'] | lowercase }]}

{[{ showTranslations['NOT_IN_STOCK_AVAILABLE_IN_FEW_DAYS'] }]}

{[{(product.sellingPrice).toFixed(2)}]} € {[{ ( product.sellingPrice - (product.shopProduct.discountOnPercentage ? (( product.sellingPrice * product.shopProduct.discount) / 100) : product.shopProduct.discount) ).toFixed(2) }]}

Geen producten beschikbaar

Sieraden bij Juwelier & Sieradenatelier Sluijsmans (2024)

References

Top Articles
Latest Posts
Article information

Author: Arline Emard IV

Last Updated:

Views: 5569

Rating: 4.1 / 5 (52 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Arline Emard IV

Birthday: 1996-07-10

Address: 8912 Hintz Shore, West Louie, AZ 69363-0747

Phone: +13454700762376

Job: Administration Technician

Hobby: Paintball, Horseback riding, Cycling, Running, Macrame, Playing musical instruments, Soapmaking

Introduction: My name is Arline Emard IV, I am a cheerful, gorgeous, colorful, joyous, excited, super, inquisitive person who loves writing and wants to share my knowledge and understanding with you.