From 158d709ee766b3792af2f1c13ab58f8cb5c77ad5 Mon Sep 17 00:00:00 2001 From: ja-ribeiro Date: Tue, 7 Jul 2026 19:46:26 -0300 Subject: [PATCH 01/14] Fix: resolves the cart localStorage overwrite issue. --- src/js/product.js | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/js/product.js b/src/js/product.js index 3868d6d..5945d0e 100644 --- a/src/js/product.js +++ b/src/js/product.js @@ -5,17 +5,8 @@ const dataSource = new ProductData('tents'); // Retrieves the existing cart array, checks for duplicates, and updates local storage function addProductToCart(product) { - const currentCart = getLocalStorage('so-cart') || []; - const existingItem = currentCart.find(item => item.Id === product.Id); - - if (existingItem) { - existingItem.Quantity = (existingItem.Quantity || 1) + 1; - } else { - product.Quantity = 1; - currentCart.push(product); - } - - setLocalStorage('so-cart', currentCart); + const cartItems = getLocalStorage("so-cart") || []; + setLocalStorage("so-cart", cartItems); } // add to cart button event handler From b6cddfb3debe65924bc51ac2a02ef9cdfc355fff Mon Sep 17 00:00:00 2001 From: ja-ribeiro Date: Tue, 7 Jul 2026 20:26:34 -0300 Subject: [PATCH 02/14] index created --- src/product_pages/index.html | 87 ++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 src/product_pages/index.html diff --git a/src/product_pages/index.html b/src/product_pages/index.html new file mode 100644 index 0000000..782252a --- /dev/null +++ b/src/product_pages/index.html @@ -0,0 +1,87 @@ + + + + + + + + + Sleep Outside | Cedar Ridge Rimrock 2-person tent + + + + + + + +
+ + + +
+ +
+
+

Cedar Ridge

+ +

Rimrock Tent - 2-Person, 3-Season

+ + Rimrock Tent - 2-Person, 3-Season + +

$69.99

+ +

Rust/Clay

+ +

+ Lightweight and ready for adventure, this Cedar Ridge Rimrock tent + boasts a weather-ready design that includes a tub-style floor and + factory-sealed rain fly +

+ +
+ +
+
+
+ +
©NOT a real business
+ + From 53553a2f99fcb66f133946aa05b407e5d13f4996 Mon Sep 17 00:00:00 2001 From: ja-ribeiro Date: Tue, 7 Jul 2026 20:27:38 -0300 Subject: [PATCH 03/14] .mjs created --- src/js/ProductDetails.mjs | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/js/ProductDetails.mjs diff --git a/src/js/ProductDetails.mjs b/src/js/ProductDetails.mjs new file mode 100644 index 0000000..e69de29 From 82ba68fa0a39eacc783263197507b2f8b78e1e43 Mon Sep 17 00:00:00 2001 From: Sebastian Iturralde Date: Wed, 8 Jul 2026 10:34:34 -0500 Subject: [PATCH 04/14] Add getParam function to retrieve URL query parameters --- src/js/utils.mjs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/js/utils.mjs b/src/js/utils.mjs index 813fae1..b7c1c19 100644 --- a/src/js/utils.mjs +++ b/src/js/utils.mjs @@ -21,3 +21,14 @@ export function setClick(selector, callback) { }); qs(selector).addEventListener('click', callback); } + +/** + * Retrieves the value of a specific parameter from the current URL's query string. + * @param {string} param - The name of the URL parameter to retrieve. + * @returns {string|null} The value of the parameter, or null if it doesn't exist. + */ +export function getParam(param) { + const queryString = window.location.search; + const urlParams = new URLSearchParams(queryString); + return urlParams.get(param); +} From 1e45d8d10b0c6922fae9d76652c9e2c74eda0cc1 Mon Sep 17 00:00:00 2001 From: Sebastian Iturralde Date: Wed, 8 Jul 2026 10:36:10 -0500 Subject: [PATCH 05/14] Add product ID retrieval from URL in product.js --- src/js/product.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/js/product.js b/src/js/product.js index 5945d0e..60f30e2 100644 --- a/src/js/product.js +++ b/src/js/product.js @@ -1,6 +1,11 @@ -import { setLocalStorage, getLocalStorage } from './utils.mjs'; +import { setLocalStorage, getLocalStorage, getParam } from './utils.mjs'; import ProductData from './ProductData.mjs'; +// Grab the product ID from the URL +const productId = getParam('product'); + +console.log(productId); // Outputs: "880RR" (based on your example link) + const dataSource = new ProductData('tents'); // Retrieves the existing cart array, checks for duplicates, and updates local storage From 962b9ea44f1e94eb54ac02cb5dadd917a4cce32c Mon Sep 17 00:00:00 2001 From: Sebastian Iturralde Date: Wed, 8 Jul 2026 10:36:50 -0500 Subject: [PATCH 06/14] Update product link to use query parameter for product ID in index.html --- src/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.html b/src/index.html index 7481511..7487419 100644 --- a/src/index.html +++ b/src/index.html @@ -64,7 +64,7 @@

Top Products