Create a Shopping Cart With Vanilla JavaScript | ES6
🎁 Join my channel to get access to perks:
/ @codeexplained
🧡 Hello All JavaScript Lovers Outhere!
Today we are going to build a JavaScript project, which is; the shopping cart using JavaScript, It will be a very clean tutorial where everything is explained very well, and a long the way this is what you will learn today:
🔸 Manipulate the DOM with JavaScript.
🔸 Render informations from a JavaScript object to the user interface.
🔸 Use of Leteral expression (backticks, multi-line string).
🔸 Using of Array.forEach() method.
🔸 Using of Array.some() method.
🔸 Using of Array.map() method.
🔸 Using of Array.filter() method.
🕔 Timeline :
00:00 - Project Preview
02:23 - Download starter template : github.com/CodeExplainedRepo/...
03:24 - Discuss Files in Start Template
05:16 - Render products
14:09 - Add Products to Cart
21:41 - Render Cart Items
28:28 - Change Number Of Units For a Product in Cart
35:17 - Calculate & Render The Subtotal
41:10 - Remove Items form Cart
44:28 - Save Cart to Local Storage
🌍 Social Media Links.
◾ Facebook : / code.explained.official
◾ Twitter : / code_explained
◾ Instagram : / code.explained.official
◾ GitHub : github.com/CodeExplainedRepo
💲 Suppport the Channel
Paypal : paypal.me/CodeExplained
Buy Me a Coffee: www.buymeacoffee.com/CodeExpl...
Пікірлер: 144
Lol tbh firstly you just did a lot for me as a freelancer I appreciate that big time... and you used all easy syntaxes in such a unique way... you sir deserve an award I appreciate you... thank you
Extremely useful tutorial as usual, many thanks for bringing this to us!
This is the very best video I found that truly helped me. It was easy to follow and straight-to-the-point. Keep up the good work! Thank you!
Best vanilla JavaScript tutorial ever, With a good and clear English, thank you sir.
@ifeomablessing9578
Жыл бұрын
💯 accurate. However I need help. When I host my project on git, the images in the array are not displaying. I need help please
Men you are so clear, simple, logical in explaining this stuff. Thank you
Please do More vanilla projects!! You're amazing Bro! Saludos desde Venezuela, tus vídeos son los mejores.. soy un fiel seguidor, extrañaba tus vídeos, espero ver muy buen material de proyectos de la vida real, que nos abren la mente, nuevamente gracias.. tu contenido, y la forma en la que explicas, es de lo mejor que he visto.
This is fantastic! Thank you for the great content! 👏
Thank you so much for this tutorial! This explanation is the best on KZread.
Thank you so much for this video. It really helped to do some homework I had and to understand very easy some concepts of JavaScript. Great teacher, congrats!
Well done and well explained. I liked how you broke down every steps and took your time explaining everything.
Thank you so much for the clear explanation. This is by far the best shopping cart tutorial I have come across.
@CodeExplained
Жыл бұрын
Wow, thank you!
Thank you for this beautiful tutorial. Your explanation is really easy to understand and I learned a lot
THIS is the best tutorial I've ever watched in my life
This guy is a legend very straight forward tnx so much man
Love ur channel. Please do more vanilla javascript projects with fetch and more.. Subscribed!
This is the best video i found that truly helped me 🌟thank you
THanks a Lot for all this information!!! very well explained
very clear and crisp explanation. Thanks a millions ❤
this tutorial is the best I could find on youtube :) Please contiunue doing amazing tutorials :D
@CodeExplained
Жыл бұрын
Oh thanks a lot buddy, happy to hear that 😊
I am beyond thankful for your detailed explanation, it helped me alot to understand the basic concept and implementation🙏
@CodeExplained
Жыл бұрын
Glad it was helpful!
This is really so well explained. I learnt a lot, Thank you.
This is the best shopping cart tutorial!!! Thank you so much
@CodeExplained
Жыл бұрын
You are so welcome!
You Rock! It's the best guide I've ever seen. Thank you so much.
@CodeExplained
Жыл бұрын
Wow, thanks!
i had to pause the video at minute 23 to drop this comment because just few minutes in and i am understanding so many concepts i didnt understand before. great job brother
Awesome !!! so easy method to create Shopping Cart ...!!!
Such a wonderful video! nicely explained. Really appreciate. Waiting for new videos.
What a great tutorial! thank you.
Thanks Bro you are doing a great work Your way of teaching is really simple Loved that
@CodeExplained
Жыл бұрын
So nice of you
thank you for your hard work. it was very informative and useful🙂
Thanks for explaining so deeply. You're doing just outstanding job, by just not typing and telling what to do just like other tutors do, even Brad traversy does that which is not good, you're explaining the line by line code and implement.
@CodeExplained
2 жыл бұрын
Yeah I always try my best to explain the logic behind ... thanks a lot for your comment.
@Sky-yy
2 жыл бұрын
@@CodeExplained this needs to be recognized coz even the paid udemy courses does that thing of coding and telling what they are doing. It should be like "what, how, why" should be answered and thats how a beginner's mind would understand how to approach logically.
@CodeExplained
2 жыл бұрын
Yeah you're right, beginners need to understand everything so they can write their own code by themselves, or they will just copy others code all the time and that will take so much time for them to learn things they can learn in a very short time ... well thanks again for your comment
@Sky-yy
2 жыл бұрын
@@CodeExplained I have landed my first job as software engineer it's been 2 months and I struggled alot. Coz I wasn't able to write code on my known coz I followed tutorials which used to teach like"typing code and tell what they were doing even in paid " no hows, where, why. I hope you create more such content, it would really add real value to people's lives. MERN project series would be awesome if you start with that.
Please do more vanilla JS projects! 🙏 these are soooo helpful
@CodeExplained
2 жыл бұрын
I will 👍
I've been eagerly waiting for your video❤️
@CodeExplained
2 жыл бұрын
Happy to hear that ❤️
Thank you so much sir for this valuable tutorial and 'easy to understand' explanation.
@CodeExplained
Жыл бұрын
Thanks and welcome
A great teacher❤
That's Great! I have been Helpful from this video, I am beginner in javascript.
@CodeExplained
Жыл бұрын
Great to hear!
That's awesome
Amazing tutorial
I love your video so much , thank you 🙏🏻
@CodeExplained
2 жыл бұрын
Happy to hear that, thanks ❤️
Thank you so much for this!!An extraordinary teacher! Easy code and explained very well
Thank you so much for this tutorial. It's of great help. However, I do have a problem. Your tutorial works just fine. But you see, I have 4 different sections (where you have the '.product's class) of products but your tutorial only works for one section and as such, I have only one section of products and 3 empty sections when I load the page. What can I do?
Wow! Good job bro, keep going.
@CodeExplained
Жыл бұрын
Thank you, I will
this is a life saver
Great.
Thank you a lot 💖
I have only 1 word for u : GOAT 🐐 ( Greatest Of All Time)
@CodeExplained
2 жыл бұрын
hahah thanks a lot ❤️
Very nice... i like this video
thanks for sharing your knowledge
@CodeExplained
Жыл бұрын
Glad to do so.
It's a really great explanation.
@CodeExplained
Жыл бұрын
Glad you think so!
Great explanation
@CodeExplained
Жыл бұрын
Glad you think so!
Wonderful live saver tutorial. Please do more vanilla js projects, like pagination, dictionary...
@CodeExplained
Жыл бұрын
Happy to hear it was helpful, yes I will.
Great Job. Is there a way to send the shopping bag to email when clicking proceed to checkout?
Nice
perfect....thanks man
@CodeExplained
Жыл бұрын
You're welcome!
you're a life saver bro
@CodeExplained
2 жыл бұрын
Happy to hear that, thanks ❤️
Its working if you have one array of object only, but if you create multiple array of object the quantity in add to cart will have a behaviour of twice amount of quantities on every button of quantity that you click in add to cart in every object inside the array of object
thanks so much
Extremly Extremly Extremly..........................useful. Thanks for the content.
@CodeExplained
Жыл бұрын
Glad it was helpful!
Nice tutorial! added an alert for if the user tries to add quantity that is not available instock. Now just wondering how to dynamically change the instock value after a purchase.
@GuitarHope
Жыл бұрын
I haven't tried it yet but I think I'd create an update function for the instock value (based on the product id) which would be called after every purchase.
veryy good tutorial , 10x
Could you possibly make another video on this project, but this time on how to make it responsive? It seems like an awesome project on the JS side, but there is a lot of overflowing when you shrink the screen.
@CodeExplained
2 жыл бұрын
Yeah I know, I didn't want to waste time on making it responsive, sorry.
@march9698
2 жыл бұрын
@@CodeExplained No need to be sorry, you did an amazing job.
I wish you 1m subscribers!
@CodeExplained
2 жыл бұрын
Thanks a lot ❤️
lots of thanks... please share the next part for checkout cart.
@CodeExplained
Жыл бұрын
Next part? What do you want for next part?
thank you !!!!
@CodeExplained
Жыл бұрын
You're welcome!
if i use json to store my data, what is the equivalent code of the function addToCart in 16:39 for it?
if I want to make a separate single product page what do I need to alter?
hi but how can i add a form with the cart like i want the user to enter his name, number etc with the cart and that to be submitted with products in the cart. i want to get the data of the cart and the form
I have been waiting more videos from you for a long time . Do you alright ?
How can you add product options like size and color ?
Thank Sir.
@CodeExplained
Жыл бұрын
You're welcome.
THANK YOU BROTHER
@CodeExplained
Жыл бұрын
You are welcome
I have a project coming up to get a online degree while most of everyone knows abouts...... this is huge help. Yup I'm aboard send all info brother.
Hi, best shopping cart tutorial, ty Sir. I have a question: min 38:50, instead of showing the price, i got NaN. Any solutions?
If I download it as a zip file then complete it and push it to my git hub will it show you as the contributor?
What vs code theme you're using?
thank you alot for this ,,
Please when are you gonna add filter cards JavaScript tutorial. I have search every where but doesn't implement it without error
I see your video of react and know how to use useContext, useEffect in real life. Could you make a project in React that use other hooks like useReducer useCallback useMemo so I can break down and analysis how and when to use them. Thank you 👍
@CodeExplained
Жыл бұрын
I'll check it out!
thanks 😊👍
@CodeExplained
2 жыл бұрын
You're welcome.
Awesome. However I need help. When I host my project on github, the images in the array are not displaying. I need help please
Is there a way to use the shopping cart on another html page? so that the shopping cart is not on the right? Because when i try that my cart doesn't render
@ifeomablessing9578
Жыл бұрын
Exactly!!!! I need help with this too.?
Nice video, but onclick event is a bit outdated, I tried to use eventlistener as an alternative somehow but didnt manage it (Im only in my first year computer science) :(
Please on your next video make a checkout page😌
Very helpful tutorial. Could you please tell me what to do if instead of stopping the user from reducing quantity below zero, I can simply remove that product from the cart when they get to zero?
@CodeExplained
Жыл бұрын
We have created a function "changeNumberOfUnits" we use the map method to change the array cart items number of units. I think you'll need to use a forEach method, and play with the "if statement" so when the numberOfUnits === 1 and the user clicks on "minus" => call the function "removeItemFromCart" If you still need help just ask.
@fatimakayy
Жыл бұрын
@@CodeExplained thank you! I figured it out
Nice Sir. Please Make More Project ... Please Please
@CodeExplained
Жыл бұрын
Thanks, of course I will
@codingislife6387
Жыл бұрын
Thank Sir.
Waiting for your new videos...➡️➡️➡️➡️➡️ Js projects
how to render the cart items on a diffrent cart page ? IM STUCK HERE :(
@CodeExplained
Жыл бұрын
I think the cart items are saved to the local storage, so when going to another page, all you need to do, is to get items from the local storage, and render them to your new page.
How would keep the number of items to be display on other pages. Im asking that because i want the number of items in cart to be in the nav bar on all my pages. The user can then click on the cart to go to cart. let me know, thank you :D love your videos.
@CodeExplained
Жыл бұрын
Save the cart to the user's browser's local storage.
@Mindinmatrix
Жыл бұрын
@@CodeExplained Thank you! I had already figured it out. I also manage to make orders and render orders to the user's profile page and much more! Your video propelled me in the right direction! Thanks again!
I want to add discount facility or buy one get free, how can I do that?
@CodeExplained
2 жыл бұрын
Add new properties to the products, { ... discount : 20, free_product: 1 } and take those in mind when calculating the subtotal.
Where is the link for your template in github?
@CodeExplained
2 жыл бұрын
github.com/CodeExplainedRepo/shopping-cart-javascript
I do not understand why this forEach of renderCartItems adding same element second time. Loop is going to another element of an array, so why previous is here too? Could you explain it more to me? ps.thanks a lot for this video man!:)
@lidijajezova2025
2 жыл бұрын
"Here" it is where?
Hi , i have try to follow code and i cannot manage changeNumberOfUnits because of onclick function.
@CodeExplained
Жыл бұрын
How can I help you?
weres the chocolate and banna javscript?
@CodeExplained
2 жыл бұрын
Coming Soon! Vanilla JS means Plain JS no framework.
Thanks for the video and please add a New video with paypal button.
helping me with my APCSP class 🫶🙏
dude is using innerHTML to create elements.. I just cant.. terrible
@CodeExplained
Жыл бұрын
hahah sorry