From e922bb6b35f4732cf869adc6e7cc25e1378f9615 Mon Sep 17 00:00:00 2001 From: sachinganesh Date: Tue, 25 Apr 2023 14:20:22 +0530 Subject: [PATCH] added direct to cart page. fixed bug in product details page. added qty valid. --- dist/Js/auth/login.js | 6 ++ dist/Js/navbar.js | 2 +- dist/Js/navbar1.js | 2 +- dist/Js/productdetails/productdetails.js | 58 ++++++++++-- dist/Js/shoppingcart/addtocart.js | 19 +++- dist/Js/shoppingcart/shoppingcart.js | 50 +++++++++-- dist/Js/utils/helpers.js | 2 +- dist/css/pages/productdetails.css | 4 + dist/css/style.css | 6 +- orderconfirmation.html | 4 +- productdetails.html | 107 ++++++++++++++++++----- 11 files changed, 210 insertions(+), 50 deletions(-) diff --git a/dist/Js/auth/login.js b/dist/Js/auth/login.js index dbec7be..912ece6 100644 --- a/dist/Js/auth/login.js +++ b/dist/Js/auth/login.js @@ -275,6 +275,12 @@ function initLogin() { window.localStorage.setItem("Useremail", userEmail); //window.localStorage.setItem("Userpassword", userPassword); window.localStorage.setItem("isaccountCreated", true); + const isCartAdded = localStorage.getItem(CART_ADD); + if(isCartAdded){ + localStorage.removeItem(CART_ADD); + window.location.href = `/selectdelivery.html`; + return; + } window.location.href = `./index.html`; } else { // toasterOpts(); diff --git a/dist/Js/navbar.js b/dist/Js/navbar.js index 8f3b766..4ccf338 100644 --- a/dist/Js/navbar.js +++ b/dist/Js/navbar.js @@ -30,7 +30,7 @@ let nav_html = `
- 0 + 0
diff --git a/dist/Js/navbar1.js b/dist/Js/navbar1.js index 0d26dab..cefacf8 100644 --- a/dist/Js/navbar1.js +++ b/dist/Js/navbar1.js @@ -29,7 +29,7 @@ let nav_html = `
- +
diff --git a/dist/Js/productdetails/productdetails.js b/dist/Js/productdetails/productdetails.js index 16a8200..b06107b 100644 --- a/dist/Js/productdetails/productdetails.js +++ b/dist/Js/productdetails/productdetails.js @@ -1,5 +1,9 @@ function startDetails(){ // http://127.0.0.1:5502/productdetails.html?productId=106633230000024 + if(window.location.search.split('=')[0] == ''){ + window.location.href = "/notfound.html"; + return; + } let productId = window.location.search.split('=')[1].split('&')[0]; console.log(productId); let itemtagscombinationRes = null; @@ -12,7 +16,7 @@ function startDetails(){ let currentClick = null; debugger; if(productId){ - getProductDetails(productId); + getProductDetails(productId); appendSpecs(productId) }else{ window.location.href = "/notfound.html" @@ -40,34 +44,71 @@ function startDetails(){ } function getSpecsItemHTML({name,des,itemid,id}){ + return `
+
+
+ ${name} +
+
+ ${des} +
+
+
`; return ` ${name} ${des} `; } + // function getSpecsItemHTML({name,des,itemid,id}){ + // return ` + // ${name} + // ${des} + // `; + // } async function appendSpecs(id){ let resData = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/itemspecifications/itemid/${id}`,true); if(resData.isError){ - + $('.productdetailstabs').addClass('d-none'); + $('.specContainerleft').html('') + $('.specContainerRight').html('') return; } - + $('.productdetailstabs ').removeClass('d-none'); const res = resData.response; console.log(JSON.parse(res.result)); const data = JSON.parse(res.result); console.log(data); let html = ''; + let leftHtml = ''; + let rightHtml = ''; + + if(data.length == 0){ + $('.productdetailstabs ').addClass('d-none'); + $('.specContainerleft').html('') + $('.specContainerRight').html('') + return; + } + for(let i=0;i{ debugger + $('.insufficientqty').addClass('d-none'); + const qty = parseInt($('#addtocart').data('qty')); + debugger; + if(parseInt($('#quantity').val())>qty){ + $('.insufficientqty').removeClass('d-none'); + return; + } $('#addtocart').off().click(function (el){ window.location.href = '/shopping-cart.html'; diff --git a/dist/Js/shoppingcart/shoppingcart.js b/dist/Js/shoppingcart/shoppingcart.js index f463adf..bee9d1d 100644 --- a/dist/Js/shoppingcart/shoppingcart.js +++ b/dist/Js/shoppingcart/shoppingcart.js @@ -5,6 +5,17 @@ function shoppingCartInit() { shoppingCartAppend(); + let insufficientQtyActions = { + moreQtyAdd(e){ + $(e.target).parents('.mainselectcontainer').find('.insufficientqty').removeClass('d-none'); + }, + + moreQtyRemove(e){ + $(e.target).parents('.mainselectcontainer').find('.insufficientqty').addClass('d-none'); + } + + } + function shoppingCartAppend() { let data = getCartData(); @@ -47,13 +58,23 @@ function shoppingCartInit() { $('.quantitySelect').each(function (i, element) { if (!$(element).hasClass('d-none')) { $(element).off().change(function (e) { + insufficientQtyActions.moreQtyRemove(e); let num = e.target.value; if (num == 5) { $(e.target).parents('.mainselectcontainer').find('.inputcartaddmore').removeClass('d-none'); $(e.target).addClass('d-none'); $(e.target).parents('.mainselectcontainer').find('.inputcartaddmore button').off().click(function (item) { - const val = $(item.target).parent().find('input').val() + const val = $(item.target).parent().find('input').val(); + debugger; + let totalQty = $(this).parents('.mainselectcontainer').data('qty'); + + if(val<=0 || totalQty< val){ + insufficientQtyActions.moreQtyAdd(e); + return; + } + let id = $(item.target).parents('.mainselectcontainer').data('id'); + updateCartQuantity(id, val); // $(item.target).parents('.mainselectcontainer').find('.inputcartaddmore').addClass('d-none'); // $(e.target).removeClass('d-none'); @@ -62,6 +83,11 @@ function shoppingCartInit() { }) } else { + const val = $(item.target).parent().find('input').val(); + if(val<=0 || totalQty< val){ + insufficientQtyActions.moreQtyAdd(e); + return; + } let id = $(e.target).parents('.mainselectcontainer').data('id'); updateCartQuantity(id, num); setLengthCart(); @@ -70,7 +96,17 @@ function shoppingCartInit() { }); } else { $(element).parents('.mainselectcontainer').find('.inputcartaddmore button').off().click(function (item) { + debugger; + const val = $(item.target).parent().find('input').val() + let totalQty = $(this).parents('.mainselectcontainer').data('qty'); + + if(val<=0 || totalQty< val){ + insufficientQtyActions.moreQtyAdd(item); + + return; + } + let id = $(item.target).parents('.mainselectcontainer').data('id'); updateCartQuantity(id, val); // $(item.target).parents('.mainselectcontainer').find('.inputcartaddmore').addClass('d-none'); @@ -132,11 +168,11 @@ function shoppingCartInit() { }); } - function getQuantityHTML(value, id) { - return `
+ function getQuantityHTML(value,totalQty, id) { + return `
- @@ -159,11 +195,11 @@ function shoppingCartInit() {
- +
Insufficient quantity
` } - function shoppingCartDesktopHTML({ id, img, name, price, description, quantity, total }) { + function shoppingCartDesktopHTML({ id, img, name, price, description, quantity, total,totalQty }) { const [currencySymbol,amt] = getCurrencySymbol(price); return `
@@ -179,7 +215,7 @@ function shoppingCartInit() {
- ${getQuantityHTML(quantity, id)} + ${getQuantityHTML(quantity,totalQty, id)}
diff --git a/dist/Js/utils/helpers.js b/dist/Js/utils/helpers.js index 4a55655..227fd20 100644 --- a/dist/Js/utils/helpers.js +++ b/dist/Js/utils/helpers.js @@ -14,7 +14,7 @@ function shuffleArray(array) { function getCurrencySymbol(value=0) { let type = 'INR' if (type) { - const ans = new Intl.NumberFormat('en-US', { style: 'currency', currency: type }).format(value);; + const ans = new Intl.NumberFormat('en-IN', { style: 'currency', currency: type }).format(value);; const res = ans.split(/(\D+)/); const currencySymbol = res[1]; const amount = res.slice(2,res.length).join('') diff --git a/dist/css/pages/productdetails.css b/dist/css/pages/productdetails.css index 5af2d05..c27f9e6 100644 --- a/dist/css/pages/productdetails.css +++ b/dist/css/pages/productdetails.css @@ -125,4 +125,8 @@ .tabsContainer .wrap-content-product-tabs{ margin-top: 40px !important; +} + +.specContainer > div{ + flex-basis: 50%; } \ No newline at end of file diff --git a/dist/css/style.css b/dist/css/style.css index b943bc9..b0e07fd 100644 --- a/dist/css/style.css +++ b/dist/css/style.css @@ -4113,7 +4113,8 @@ margin-bottom: 0.5rem !important; font-weight: 600;; } */ .main-menu > nav > ul > li:hover > a { - color: #0A1039; + /* color: #0A1039; */ + color:white; } .main-menu > nav > ul > li > ul { @@ -4505,7 +4506,8 @@ margin-bottom: 0.5rem !important; } .main-menu.main-menu-white > nav > ul > li:hover > a { - color: #0A1039; + /* color: #0A1039; */ + color:white; } .main-menu.menu-lh-1 > nav > ul > li > a { diff --git a/orderconfirmation.html b/orderconfirmation.html index 111b3b8..76c51a3 100644 --- a/orderconfirmation.html +++ b/orderconfirmation.html @@ -25,7 +25,7 @@
-
+
@@ -116,7 +116,7 @@ - + diff --git a/productdetails.html b/productdetails.html index 14ba753..a4fb028 100644 --- a/productdetails.html +++ b/productdetails.html @@ -48,7 +48,13 @@ -
+
+
+
+
+
+
+
@@ -90,7 +96,7 @@
-
+
@@ -280,6 +286,7 @@
+
Insufficient quantity
-->
-
+ + +
--> +
+
+
+
+
+ Manufacturer +
+
+ 26/F TOWER ONE TIME SQUARE 1 MATHESON STREET CAUSEWAY BAY HK +
+
+
+
+
+
+ Model Name +
+
+ ‎ORA 16 GB RAM DDR5 SDRAM 4800 MHz +
+
+
+
+
+
+ Product Dimensions +
+
+ 8 x 3.1 x 0.3 cm; 10 Grams +
+
+
+ +
+
+ +
+
+
+ Item part number +
+
+ AWLD54816M +
+
+
+
+
+
+ RAM Size +
+
+ 16 GB +
+
+
+
+
+
+ Ram Memory Technology +
+
+ DDR5, SO-DIMM + +
+
+
+
@@ -368,11 +425,13 @@ + - + +