From 05344fb6fc07481edceda8a3854fc56e16442137 Mon Sep 17 00:00:00 2001 From: PURVA ATHNERE <93878803+purvathnere@users.noreply.github.com> Date: Sun, 16 Jun 2024 14:42:59 +0530 Subject: [PATCH 1/2] Update viewcart --- viewcart/viewcart.js | 52 ++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/viewcart/viewcart.js b/viewcart/viewcart.js index 172262e7..7d41839b 100644 --- a/viewcart/viewcart.js +++ b/viewcart/viewcart.js @@ -1,4 +1,4 @@ -//Date and Time +// Date and Time const today = new Date(); const nextThreeDays = new Date(today); nextThreeDays.setDate(today.getDate() + 3); @@ -7,8 +7,9 @@ const daysOfWeek = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Fri const dayOfWeek = daysOfWeek[nextThreeDays.getDay()]; const date = nextThreeDays.toLocaleDateString(); -//Cart JS -//Function to save data to local storage +// Cart JS + +// Function to save data to local storage function saveToLocalStorage(key, newData) { let existingData = getFromLocalStorage(key) || []; @@ -60,10 +61,20 @@ function fetchCartData(item) { totalItems += 1; totalPrice += item.price; + const discont=(Math.floor(item.rating*(parseInt((item.price.toString()).slice(0,2)))/10)) + const afterDiscontPrice=Math.round((100-discont)*item.price/100) + + function formatIndianRupee(number) { + const parts = number.toString().split("."); + const integerPart = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); + const formattedNumber = parts.length > 1 ? integerPart + "." + parts[1] : integerPart; + return formattedNumber; + } + return `
Forest Green Strap, Regular
Seller: Ezig