Go to project: Gitz’s Grocery Store
Welcome to my grocery store!
Here you can shop to your heart’s desire! Well… not really, I only have 8 products, and they are all virtual.
As I am hoping to work with webshops in the future, the BF thought it would be a good idea to make a shopping cart function myself. Some of the products have discounts. Some discounts are 50% discounts and others are 2 for 1. Happy shopping!
I coded, I learned:
- The most used function I made was the updateShoppingCart function. It’s being called every time something changes, for example that the user is adding a product to the cart.
- I made an array with the products, that can be “purchased”. Then we made another array which started out empty and then as the user added products, they were pushed in to the second array. This way we could count how many times one product existed in the second array and use that number to make the count feature in the shopping cart.
- In the first array, we also added some different discount types and hooked them up.