Преглед на файлове

added direct to cart page. fixed bug in product details page. added qty valid.

sachinganesh преди 2 години
родител
ревизия
e922bb6b35

+ 6
- 0
dist/Js/auth/login.js Целия файл

@@ -275,6 +275,12 @@ function initLogin() {
275 275
           window.localStorage.setItem("Useremail", userEmail);
276 276
           //window.localStorage.setItem("Userpassword", userPassword);
277 277
           window.localStorage.setItem("isaccountCreated", true);
278
+          const isCartAdded = localStorage.getItem(CART_ADD);
279
+          if(isCartAdded){
280
+            localStorage.removeItem(CART_ADD);
281
+            window.location.href = `/selectdelivery.html`;
282
+            return;
283
+          }
278 284
           window.location.href = `./index.html`;
279 285
         } else {
280 286
         //   toasterOpts();

+ 1
- 1
dist/Js/navbar.js Целия файл

@@ -30,7 +30,7 @@ let nav_html = `
30 30
                                 </div>
31 31
                                 <div class="same-style header-cart">
32 32
                                 <a class="cart-active1 position-relative" href="./shopping-cart.html"><i class="fa-solid fa-cart-shopping"></i>
33
-                                <span class="position-absolute cartnumcount d-none"  style="top:-27%;right:-80%">0</span>
33
+                                <span class="position-absolute cartnumcount d-none"  style="top:-15%;right:-115%">0</span>
34 34
                                 </a>
35 35
                                 </div>
36 36
                             </div>

+ 1
- 1
dist/Js/navbar1.js Целия файл

@@ -29,7 +29,7 @@ let nav_html = `
29 29
                                 <a href="./myaccount.html" class="my_avatar"><i class="fa-solid fa-user"></i></a>
30 30
                                 </div>
31 31
                                 <div class="same-style header-cart">
32
-                                    <a class="cart-active1" href="#"><i class="fa-solid fa-cart-shopping"></i></a>
32
+                                    <a class="cart-active1" href="/shopping-cart.html"><i class="fa-solid fa-cart-shopping"></i></a>
33 33
                                 </div>
34 34
                             </div>
35 35
                         </div>

+ 50
- 8
dist/Js/productdetails/productdetails.js Целия файл

@@ -1,5 +1,9 @@
1 1
 function startDetails(){
2 2
     // http://127.0.0.1:5502/productdetails.html?productId=106633230000024
3
+    if(window.location.search.split('=')[0] == ''){
4
+        window.location.href = "/notfound.html";
5
+        return;
6
+    }
3 7
     let productId = window.location.search.split('=')[1].split('&')[0];
4 8
     console.log(productId);
5 9
     let itemtagscombinationRes = null;
@@ -12,7 +16,7 @@ function startDetails(){
12 16
     let currentClick = null;
13 17
     debugger;
14 18
     if(productId){
15
-        getProductDetails(productId);
19
+       getProductDetails(productId);
16 20
         appendSpecs(productId)
17 21
     }else{
18 22
        window.location.href = "/notfound.html"
@@ -40,34 +44,71 @@ function startDetails(){
40 44
     }
41 45
 
42 46
     function getSpecsItemHTML({name,des,itemid,id}){
47
+        return `<div id="${id}" data-specitemid="${itemid}" class="">
48
+        <div class="row  border-bottom">
49
+            <div class="col-sm-6 bg-gray-3 py-2">
50
+            ${name}
51
+            </div>
52
+            <div class="col-sm-6  py-2">
53
+            ${des}	
54
+            </div>
55
+        </div>
56
+    </div>`;
43 57
         return ` <tr id="${id}" data-specitemid="${itemid}">
44 58
         <td style="width:200px">${name}</td>
45 59
         <td class="">${des}</td>
46 60
     </tr>`;
47 61
     }
62
+    // function getSpecsItemHTML({name,des,itemid,id}){
63
+    //     return ` <tr id="${id}" data-specitemid="${itemid}">
64
+    //     <td style="width:200px">${name}</td>
65
+    //     <td class="">${des}</td>
66
+    // </tr>`;
67
+    // }
48 68
 
49 69
     async function appendSpecs(id){
50 70
         let resData = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/itemspecifications/itemid/${id}`,true);
51 71
 
52 72
         if(resData.isError){
53
-
73
+            $('.productdetailstabs').addClass('d-none');
74
+            $('.specContainerleft').html('')
75
+        $('.specContainerRight').html('')
54 76
             return;
55 77
         }
56
-
78
+        $('.productdetailstabs ').removeClass('d-none');
57 79
         const res = resData.response;
58 80
         console.log(JSON.parse(res.result));
59 81
         const data = JSON.parse(res.result);
60 82
         console.log(data);
61 83
         let html = '';
84
+        let leftHtml = '';
85
+        let rightHtml = '';
86
+
87
+        if(data.length == 0){
88
+            $('.productdetailstabs ').addClass('d-none');
89
+            $('.specContainerleft').html('')
90
+            $('.specContainerRight').html('')
91
+            return;
92
+        }
93
+
62 94
         for(let i=0;i<data.length;i++){
63 95
             const {specificationname,specificationitemid,itemid,description} = data[i];
64
-            html += getSpecsItemHTML({
65
-                name:specificationname,id:specificationitemid,itemid,des:description
66
-            });
96
+            if((i+1)%2 == 0){
97
+                rightHtml += getSpecsItemHTML({
98
+                    name:specificationname,id:specificationitemid,itemid,des:description
99
+                })
100
+            }else{
101
+                leftHtml += getSpecsItemHTML({
102
+                    name:specificationname,id:specificationitemid,itemid,des:description
103
+                });
104
+            }
105
+            
67 106
         }
68 107
         debugger;
69 108
         
70
-        $('.append-specs').html(html)
109
+        $('.specContainerleft').html(leftHtml)
110
+        $('.specContainerRight').html(rightHtml)
111
+
71 112
     }
72 113
    
73 114
 
@@ -116,6 +157,7 @@ function startDetails(){
116 157
         appendSpecs(obj.itemid)
117 158
         $('#skudetailitem').val(obj.sku)
118 159
         $('.des_productdes').html(obj.itemdescription);
160
+        $('#addtocart').attr('data-qty',obj.quantity)
119 161
         
120 162
         let defaultImg = obj.itemimageurl ? imgServerNameBuild(obj.itemimageurl): `./dist/assets/imgs/nophoto.png`;
121 163
 console.log(obj.itemimageurl,'obj.itemimageurlobj.itemimageurlobj.itemimageurl');
@@ -343,7 +385,7 @@ debugger;
343 385
         });
344 386
         debugger;
345 387
         let searchParams = window.location.search.split("&");
346
-        let skuId = window.location.hash.split('=')[1];
388
+        let skuId = window.location.hash.split('#')[1].split('=')[1];
347 389
         // skuId = skuId.split('=')[1]
348 390
         let isGo = true;
349 391
         for(let i=0;i<itemtagscombinationRes.length;i++){

+ 15
- 4
dist/Js/shoppingcart/addtocart.js Целия файл

@@ -112,8 +112,9 @@ function initAddToCart(){
112 112
         const data = getCartData();
113 113
           
114 114
         let id =  window.location.search.split('=')[1];
115
+        const qty = parseInt($('#addtocart').data('qty'));
115 116
         if(!data){
116
-          
117
+            
117 118
             let cartObj = {};
118 119
            debugger;
119 120
       
@@ -122,7 +123,8 @@ function initAddToCart(){
122 123
                 price:$('.price').html(),
123 124
                 quantity:$('#quantity').val(),
124 125
                 img:$('.productDetailsMain img').attr('src'),
125
-                sku:$('#skudetailitem').val()
126
+                sku:$('#skudetailitem').val(),
127
+                totalQty:qty
126 128
             }
127 129
 
128 130
 
@@ -146,7 +148,8 @@ function initAddToCart(){
146 148
                     price:price,
147 149
                     quantity: parseInt(data[sku].quantity)+parseInt(quantity),
148 150
                     img:img,
149
-                    sku:sku
151
+                    sku:sku,
152
+                    totalQty:qty
150 153
                 }
151 154
                 addtoCart(data);
152 155
             }else{
@@ -155,7 +158,8 @@ function initAddToCart(){
155 158
                     price:price,
156 159
                     quantity:parseInt(quantity),
157 160
                     img:img,
158
-                    sku:sku
161
+                    sku:sku,
162
+                    totalQty:qty
159 163
                 }
160 164
                 addtoCart(data);
161 165
             }
@@ -170,6 +174,13 @@ function initAddToCart(){
170 174
         $('#addtocart').html('Add to cart')
171 175
         $('#addtocart').off().click((e)=>{
172 176
             debugger    
177
+            $('.insufficientqty').addClass('d-none');
178
+            const qty = parseInt($('#addtocart').data('qty'));
179
+            debugger;
180
+            if(parseInt($('#quantity').val())>qty){
181
+                $('.insufficientqty').removeClass('d-none');
182
+                return;
183
+            }
173 184
             $('#addtocart').off().click(function (el){
174 185
                 window.location.href = '/shopping-cart.html';
175 186
 

+ 43
- 7
dist/Js/shoppingcart/shoppingcart.js Целия файл

@@ -5,6 +5,17 @@ function shoppingCartInit() {
5 5
 
6 6
     shoppingCartAppend();
7 7
 
8
+    let insufficientQtyActions = {
9
+        moreQtyAdd(e){
10
+            $(e.target).parents('.mainselectcontainer').find('.insufficientqty').removeClass('d-none');
11
+        },
12
+
13
+        moreQtyRemove(e){
14
+            $(e.target).parents('.mainselectcontainer').find('.insufficientqty').addClass('d-none');
15
+        }
16
+        
17
+    }
18
+
8 19
     function shoppingCartAppend() {
9 20
         let data = getCartData();
10 21
 
@@ -47,13 +58,23 @@ function shoppingCartInit() {
47 58
         $('.quantitySelect').each(function (i, element) {
48 59
             if (!$(element).hasClass('d-none')) {
49 60
                 $(element).off().change(function (e) {
61
+                    insufficientQtyActions.moreQtyRemove(e);
50 62
                     let num = e.target.value;
51 63
                     if (num == 5) {
52 64
                         $(e.target).parents('.mainselectcontainer').find('.inputcartaddmore').removeClass('d-none');
53 65
                         $(e.target).addClass('d-none');
54 66
                         $(e.target).parents('.mainselectcontainer').find('.inputcartaddmore button').off().click(function (item) {
55
-                            const val = $(item.target).parent().find('input').val()
67
+                            const val = $(item.target).parent().find('input').val();
68
+                            debugger;
69
+                            let totalQty  = $(this).parents('.mainselectcontainer').data('qty');
70
+
71
+                            if(val<=0 || totalQty< val){
72
+                                insufficientQtyActions.moreQtyAdd(e);
73
+                                return; 
74
+                            }
75
+
56 76
                             let id = $(item.target).parents('.mainselectcontainer').data('id');
77
+
57 78
                             updateCartQuantity(id, val);
58 79
                             //    $(item.target).parents('.mainselectcontainer').find('.inputcartaddmore').addClass('d-none');
59 80
                             //    $(e.target).removeClass('d-none');
@@ -62,6 +83,11 @@ function shoppingCartInit() {
62 83
 
63 84
                         })
64 85
                     } else {
86
+                        const val = $(item.target).parent().find('input').val();
87
+                        if(val<=0 || totalQty< val){
88
+                            insufficientQtyActions.moreQtyAdd(e);
89
+                            return; 
90
+                        }
65 91
                         let id = $(e.target).parents('.mainselectcontainer').data('id');
66 92
                         updateCartQuantity(id, num);
67 93
                         setLengthCart();
@@ -70,7 +96,17 @@ function shoppingCartInit() {
70 96
                 });
71 97
             } else {
72 98
                 $(element).parents('.mainselectcontainer').find('.inputcartaddmore button').off().click(function (item) {
99
+                    debugger;
100
+                  
73 101
                     const val = $(item.target).parent().find('input').val()
102
+                    let totalQty  = $(this).parents('.mainselectcontainer').data('qty');
103
+
104
+                    if(val<=0 || totalQty< val){
105
+                        insufficientQtyActions.moreQtyAdd(item);
106
+                      
107
+                        return; 
108
+                    }
109
+                   
74 110
                     let id = $(item.target).parents('.mainselectcontainer').data('id');
75 111
                     updateCartQuantity(id, val);
76 112
                     //    $(item.target).parents('.mainselectcontainer').find('.inputcartaddmore').addClass('d-none');
@@ -132,11 +168,11 @@ function shoppingCartInit() {
132 168
         });
133 169
     }
134 170
 
135
-    function getQuantityHTML(value, id) {
136
-        return `<div data-id="${id}" class="mainselectcontainer w-100">
171
+    function getQuantityHTML(value,totalQty, id) {
172
+        return `<div data-id="${id}" data-qty="${totalQty}" class="mainselectcontainer w-100">
137 173
         <div class="w-50">
138 174
        
139
-        <select class="quantitySelect form-select ${value >= 5 ? 'd-none' : ''}" value="${value}">
175
+        <select  class="quantitySelect form-select ${value >= 5 ? 'd-none' : ''}" value="${value}">
140 176
                 <option ${value == 1 ? 'selected="selected"' : null} value="1">
141 177
                     1
142 178
                 </option>
@@ -159,11 +195,11 @@ function shoppingCartInit() {
159 195
         <input min="1" class="form-control" style="max-width:100px" value="${value <= 5 ? '5' : value}" type="number" />
160 196
         <button class="btn border-none bg-info">Add</button>
161 197
     </div>
162
-        
198
+        <div class="text-danger pt-2 insufficientqty d-none">Insufficient quantity</div>
163 199
         </div>`
164 200
     }
165 201
 
166
-    function shoppingCartDesktopHTML({ id, img, name, price, description, quantity, total }) {
202
+    function shoppingCartDesktopHTML({ id, img, name, price, description, quantity, total,totalQty }) {
167 203
         const [currencySymbol,amt] = getCurrencySymbol(price);
168 204
         return `
169 205
         <div class="row bg-white  border-bottom py-4 d-flex justify-content-center align-items-center">
@@ -179,7 +215,7 @@ function shoppingCartInit() {
179 215
         </div>
180 216
         <div class="col-md-2 ">
181 217
    
182
-            ${getQuantityHTML(quantity, id)}
218
+            ${getQuantityHTML(quantity,totalQty, id)}
183 219
         </div>
184 220
         <div class="col-md-2 ">
185 221
             <div class="d-flex justify-content-between w-100">

+ 1
- 1
dist/Js/utils/helpers.js Целия файл

@@ -14,7 +14,7 @@ function shuffleArray(array) {
14 14
 function getCurrencySymbol(value=0) {
15 15
     let type = 'INR'
16 16
     if (type) {
17
-        const ans = new Intl.NumberFormat('en-US', { style: 'currency', currency: type }).format(value);;
17
+        const ans = new Intl.NumberFormat('en-IN', { style: 'currency', currency: type }).format(value);;
18 18
         const res = ans.split(/(\D+)/);
19 19
         const currencySymbol = res[1];
20 20
         const amount = res.slice(2,res.length).join('')

+ 4
- 0
dist/css/pages/productdetails.css Целия файл

@@ -125,4 +125,8 @@
125 125
 
126 126
 .tabsContainer .wrap-content-product-tabs{
127 127
     margin-top: 40px !important;
128
+}
129
+
130
+.specContainer > div{
131
+    flex-basis: 50%;
128 132
 }

+ 4
- 2
dist/css/style.css Целия файл

@@ -4113,7 +4113,8 @@ margin-bottom: 0.5rem !important;
4113 4113
   font-weight: 600;;
4114 4114
 } */
4115 4115
 .main-menu > nav > ul > li:hover > a {
4116
-  color: #0A1039;
4116
+  /* color: #0A1039; */
4117
+  color:white;
4117 4118
 }
4118 4119
 
4119 4120
 .main-menu > nav > ul > li > ul {
@@ -4505,7 +4506,8 @@ margin-bottom: 0.5rem !important;
4505 4506
 }
4506 4507
 
4507 4508
 .main-menu.main-menu-white > nav > ul > li:hover > a {
4508
-  color: #0A1039;
4509
+  /* color: #0A1039; */
4510
+  color:white;
4509 4511
 }
4510 4512
 
4511 4513
 .main-menu.menu-lh-1 > nav > ul > li > a {

+ 2
- 2
orderconfirmation.html Целия файл

@@ -25,7 +25,7 @@
25 25
     <!-- main-body -->
26 26
     <auth-loader></auth-loader>
27 27
     <main class="orderconfirmationMain">
28
-        <section class="container d-flex justify-content-center">
28
+        <section class="container d-flex justify-content-center p-md-5">
29 29
             <div class="ordercontainerconfirm ordercontainerconfirmError d-none  d-flex flex-column align-items-center justify-content-center">
30 30
                 <div class="p-3">
31 31
                     <div class="text-center text-danger font-5">
@@ -116,7 +116,7 @@
116 116
 
117 117
     <script src="./libs/bootstrap/js/bootstrap.bundle.min.js"></script>
118 118
     <script src="./dist/js/jquery.min.js"></script>
119
-    <script src="./dist/js/navbar.js"></script>
119
+    <script src="./dist/js/navbar1.js"></script>
120 120
 
121 121
     <script src="./dist/js/footer.js"></script>
122 122
     <script src="./libs/cookies.min.js"></script>

+ 83
- 24
productdetails.html Целия файл

@@ -48,7 +48,13 @@
48 48
     <div id="navbar-head"></div>
49 49
     <!-- end-navbar -->
50 50
     <!-- main-body -->
51
-    <main class="main-body home-main-container" style="margin-top: 30px;">
51
+    <main class="main-body home-main-container">
52
+        <section class="services h-100 pt-3  bg-gradient-anwi">
53
+            <div class="container pt-5 ">
54
+                <div class="text-center text-white ">
55
+                </div>
56
+            </div>
57
+        </section>
52 58
         <div class="container mainContanierProduct">
53 59
             <div class="row">
54 60
                 <div class="col-xl-7 ">
@@ -90,7 +96,7 @@
90 96
                         </div>
91 97
                     </div>
92 98
                 </div>
93
-                <div class="col-xl-5 p-5 productDetailsShadow">
99
+                <div class="col-xl-5 p-5 pt-0 productDetailsShadow">
94 100
                     <div class="card border-0">
95 101
                         <div>
96 102
                             <div>
@@ -280,6 +286,7 @@
280 286
                                 <option value="4">4</option>
281 287
                             </select>
282 288
                         </div>
289
+                        <div class="text-danger pt-2 insufficientqty d-none">Insufficient quantity</div>
283 290
                         <div class=" d-flex  gap-2">
284 291
                             <button id="addtocart" class="w-100 btn bg-black text-white" style="border-radius: 5px;">
285 292
                                 Add to cart
@@ -312,7 +319,7 @@
312 319
                             </div>
313 320
                         </div> -->
314 321
                         <div id="des-details2" class="tab-pane active show" role="tabpanel">
315
-                            <div class="specification-wrap table-responsive">
322
+                            <!-- <div class="specification-wrap table-responsive">
316 323
                                 <table class="table table-bordered wrap-content-product-tabs">
317 324
                                     <tbody class="append-specs">
318 325
                                         <tr>
@@ -323,28 +330,78 @@
323 330
                                             <td>Memory Speed</td>
324 331
                                             <td>3200</td>
325 332
                                         </tr>
326
-                                        <!-- <tr>
327
-                                            <td class="width1">Models</td>
328
-                                            <td>FX 829 v1</td>
329
-                                        </tr>
330
-                                        <tr>
331
-                                            <td class="width1">Categories</td>
332
-                                            <td>Digital Print</td>
333
-                                        </tr>
334
-                                        <tr>
335
-                                            <td class="width1">Size</td>
336
-                                            <td>60’’ x 40’’</td>
337
-                                        </tr>
338
-                                        <tr>
339
-                                            <td class="width1">Brand </td>
340
-                                            <td>Individual Collections</td>
341
-                                        </tr>
342
-                                        <tr>
343
-                                            <td class="width1">Color</td>
344
-                                            <td>Black, White</td>
345
-                                        </tr> -->
333
+                                       
346 334
                                     </tbody>
347 335
                                 </table>
336
+                            </div> -->
337
+                            <div class="d-flex gap-5 specContainer mt-3">
338
+                                <div  class="specContainerleft">
339
+                                    <div class="">
340
+                                        <div class="row  border-bottom">
341
+                                            <div class="col-sm-6 bg-gray-3">
342
+                                                Manufacturer	
343
+                                            </div>
344
+                                            <div class="col-sm-6">
345
+                                                26/F TOWER ONE TIME SQUARE 1 MATHESON STREET CAUSEWAY BAY HK	
346
+                                            </div>
347
+                                        </div>
348
+                                    </div>
349
+                                    <div class="">
350
+                                        <div class="row  border-bottom">
351
+                                            <div class="col-sm-6 bg-gray-3">
352
+                                                Model Name	
353
+                                            </div>
354
+                                            <div class="col-sm-6">
355
+                                                ‎ORA 16 GB RAM DDR5 SDRAM 4800 MHz
356
+                                            </div>
357
+                                        </div>
358
+                                    </div>
359
+                                    <div class="">
360
+                                        <div class="row  border-bottom">
361
+                                            <div class="col-sm-6 bg-gray-3">
362
+                                                Product Dimensions	
363
+                                            </div>
364
+                                            <div class="col-sm-6">
365
+                                                8 x 3.1 x 0.3 cm; 10 Grams  
366
+                                            </div>
367
+                                        </div>
368
+                                    </div>
369
+                                   
370
+                                </div>
371
+                                <div class="specContainerRight">
372
+                                    
373
+                                    <div class="">
374
+                                        <div class="row  border-bottom">
375
+                                            <div class="col-sm-6 bg-gray-3">
376
+                                                Item part number
377
+                                            </div>
378
+                                            <div class="col-sm-6">
379
+                                                AWLD54816M
380
+                                            </div>
381
+                                        </div>
382
+                                    </div>
383
+                                    <div class="">
384
+                                        <div class="row  border-bottom">
385
+                                            <div class="col-sm-6 bg-gray-3">
386
+                                                RAM Size	
387
+                                            </div>
388
+                                            <div class="col-sm-6">
389
+                                                16 GB
390
+                                            </div>
391
+                                        </div>
392
+                                    </div>
393
+                                    <div class="">
394
+                                        <div class="row  border-bottom">
395
+                                            <div class="col-sm-6 bg-gray-3">
396
+                                                Ram Memory Technology	
397
+                                            </div>
398
+                                            <div class="col-sm-6">
399
+                                                DDR5, SO-DIMM
400
+    
401
+                                            </div>
402
+                                        </div>
403
+                                    </div>
404
+                                </div>
348 405
                             </div>
349 406
                         </div>
350 407
                        
@@ -368,11 +425,13 @@
368 425
     <script src="./dist/js/fontawesome.min.js"></script>
369 426
     <script src="./dist/js/vendor/bootstrap.min.js"></script>
370 427
 
428
+
371 429
     <!--  -->
372 430
     <!-- <script src="./libs/toaster/toastr.js"></script> -->
373 431
     <script src="./dist/toaster/toastr.js"></script>
374 432
     <script src="./libs/bootstrap/js/bootstrap.bundle.min.js"></script>
375
-    <script src="./dist/Js/jquery.min.js"></script>
433
+    <script src="./dist/js/jquery.min.js"></script>
434
+    <script src="./dist/js/main.js"></script>
376 435
 
377 436
 
378 437
 

Loading…
Отказ
Запис