An open API service indexing awesome lists of open source software.

https://github.com/cudi7/javascript_shopping-cart

Simple shopping cart App using JavaScript, HTML and CSS
https://github.com/cudi7/javascript_shopping-cart

css html javascript shopping-cart

Last synced: about 1 year ago
JSON representation

Simple shopping cart App using JavaScript, HTML and CSS

Awesome Lists containing this project

README

          

# Shopping Cart app build with JavaScript

# Live demo

> https://pensive-mccarthy-f9998a.netlify.app

![Design preview for the coding challenge](./Screenshot_1.jpg)
![Design preview for the coding challenge](./Screenshot_2.jpg)

## Table of contents

- [General info](#general-info)
- [Code Examples](#code-examples)
- [Features](#features)
- [Contact](#contact)

## General info

- Responsive, build with HTML/CSS/JS.

## Code Examples

./js/products.js

```
// loop thorough data and display each field
function displayData(data) {
data.items.forEach((item, index) => {
const div = document.createElement('div');
div.classList.add('product-item');
div.id = item.sys.id;

div.innerHTML = `


${item.fields.title}



product ${index + 1}

${item.fields.price} $

Add product

`;

productContainer.append(div);
});

loadListeners();
loadPreviousCart();
loadPreviousQtyCart();
}

function loadListeners() {
const addCartBtn = document.querySelectorAll('.add-cart');

addCartBtn.forEach((btn) => btn.addEventListener('click', handleAddProduct));
}

function loadPreviousCart() {
const prevCart = getLocalStorage('currentCart');
currentCart = prevCart ? prevCart : [];
prevCart && displayCartItems(currentCart);
}

function loadPreviousQtyCart() {
displayCartIcon('initialState');
}
```

## Features

- Everything saves to localStorage
- You can see your cart number updating as you add more items

You can:

- Add a product
- Change quantity
- Delete product

## Technology used

The project is created with:

- JavaScript

## Contact

Coded by Cudi - feel free to contact me!