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

  • @rfryanfavour4369
    @rfryanfavour43692 жыл бұрын

    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

  • @elieli2570
    @elieli25702 жыл бұрын

    Extremely useful tutorial as usual, many thanks for bringing this to us!

  • @bbogomilov
    @bbogomilov2 жыл бұрын

    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!

  • @solomonjackson7984
    @solomonjackson7984 Жыл бұрын

    Best vanilla JavaScript tutorial ever, With a good and clear English, thank you sir.

  • @ifeomablessing9578

    @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

  • @maxmaksum4673
    @maxmaksum46732 жыл бұрын

    Men you are so clear, simple, logical in explaining this stuff. Thank you

  • @CAFernandezB
    @CAFernandezB2 жыл бұрын

    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.

  • @dtawantawng5131
    @dtawantawng5131 Жыл бұрын

    This is fantastic! Thank you for the great content! 👏

  • @stevenfranz5462
    @stevenfranz5462 Жыл бұрын

    Thank you so much for this tutorial! This explanation is the best on KZread.

  • @teyuu
    @teyuu2 жыл бұрын

    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!

  • @kambatukebele
    @kambatukebele8 ай бұрын

    Well done and well explained. I liked how you broke down every steps and took your time explaining everything.

  • @ummasiyah3238
    @ummasiyah32382 жыл бұрын

    Thank you so much for the clear explanation. This is by far the best shopping cart tutorial I have come across.

  • @CodeExplained

    @CodeExplained

    Жыл бұрын

    Wow, thank you!

  • @frontendwithsalimi
    @frontendwithsalimi2 жыл бұрын

    Thank you for this beautiful tutorial. Your explanation is really easy to understand and I learned a lot

  • @rfryanfavour4369
    @rfryanfavour43692 жыл бұрын

    THIS is the best tutorial I've ever watched in my life

  • @revayuap972
    @revayuap972 Жыл бұрын

    This guy is a legend very straight forward tnx so much man

  • @irwankaryantotandek6058
    @irwankaryantotandek60582 жыл бұрын

    Love ur channel. Please do more vanilla javascript projects with fetch and more.. Subscribed!

  • @negin3408
    @negin3408 Жыл бұрын

    This is the best video i found that truly helped me 🌟thank you

  • @andrisalazar7565
    @andrisalazar75652 жыл бұрын

    THanks a Lot for all this information!!! very well explained

  • @shahhussain5563
    @shahhussain5563 Жыл бұрын

    very clear and crisp explanation. Thanks a millions ❤

  • @vt9988
    @vt9988 Жыл бұрын

    this tutorial is the best I could find on youtube :) Please contiunue doing amazing tutorials :D

  • @CodeExplained

    @CodeExplained

    Жыл бұрын

    Oh thanks a lot buddy, happy to hear that 😊

  • @dindindongi
    @dindindongi2 жыл бұрын

    I am beyond thankful for your detailed explanation, it helped me alot to understand the basic concept and implementation🙏

  • @CodeExplained

    @CodeExplained

    Жыл бұрын

    Glad it was helpful!

  • @marymaundu1702
    @marymaundu17026 ай бұрын

    This is really so well explained. I learnt a lot, Thank you.

  • @dansmar_2414
    @dansmar_24142 жыл бұрын

    This is the best shopping cart tutorial!!! Thank you so much

  • @CodeExplained

    @CodeExplained

    Жыл бұрын

    You are so welcome!

  • @lastley7886
    @lastley7886 Жыл бұрын

    You Rock! It's the best guide I've ever seen. Thank you so much.

  • @CodeExplained

    @CodeExplained

    Жыл бұрын

    Wow, thanks!

  • @bensonbenson4149
    @bensonbenson41496 ай бұрын

    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

  • @ashrafulmomenshuvo5344
    @ashrafulmomenshuvo5344 Жыл бұрын

    Awesome !!! so easy method to create Shopping Cart ...!!!

  • @mmonir2061
    @mmonir2061 Жыл бұрын

    Such a wonderful video! nicely explained. Really appreciate. Waiting for new videos.

  • @mackinlay27
    @mackinlay2711 ай бұрын

    What a great tutorial! thank you.

  • @AjayKumar-id7mb
    @AjayKumar-id7mb2 жыл бұрын

    Thanks Bro you are doing a great work Your way of teaching is really simple Loved that

  • @CodeExplained

    @CodeExplained

    Жыл бұрын

    So nice of you

  • @someChicoRy
    @someChicoRy Жыл бұрын

    thank you for your hard work. it was very informative and useful🙂

  • @Sky-yy
    @Sky-yy2 жыл бұрын

    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

    @CodeExplained

    2 жыл бұрын

    Yeah I always try my best to explain the logic behind ... thanks a lot for your comment.

  • @Sky-yy

    @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

    @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

    @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.

  • @ambareen2368
    @ambareen23682 жыл бұрын

    Please do more vanilla JS projects! 🙏 these are soooo helpful

  • @CodeExplained

    @CodeExplained

    2 жыл бұрын

    I will 👍

  • @lokeshkhati8413
    @lokeshkhati84132 жыл бұрын

    I've been eagerly waiting for your video❤️

  • @CodeExplained

    @CodeExplained

    2 жыл бұрын

    Happy to hear that ❤️

  • @gopalakrishnachinta3769
    @gopalakrishnachinta37692 жыл бұрын

    Thank you so much sir for this valuable tutorial and 'easy to understand' explanation.

  • @CodeExplained

    @CodeExplained

    Жыл бұрын

    Thanks and welcome

  • @user-xh2xb8ly3k
    @user-xh2xb8ly3k4 ай бұрын

    A great teacher❤

  • @howtodo9412
    @howtodo94122 жыл бұрын

    That's Great! I have been Helpful from this video, I am beginner in javascript.

  • @CodeExplained

    @CodeExplained

    Жыл бұрын

    Great to hear!

  • @mateenmahi
    @mateenmahi10 ай бұрын

    That's awesome

  • @_myenglishbro
    @_myenglishbro Жыл бұрын

    Amazing tutorial

  • @fishmarkholmes1834
    @fishmarkholmes18342 жыл бұрын

    I love your video so much , thank you 🙏🏻

  • @CodeExplained

    @CodeExplained

    2 жыл бұрын

    Happy to hear that, thanks ❤️

  • @alinabianca3934
    @alinabianca39346 ай бұрын

    Thank you so much for this!!An extraordinary teacher! Easy code and explained very well

  • @deeeera
    @deeeera2 жыл бұрын

    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?

  • @thientinhlamhuynh3004
    @thientinhlamhuynh30042 жыл бұрын

    Wow! Good job bro, keep going.

  • @CodeExplained

    @CodeExplained

    Жыл бұрын

    Thank you, I will

  • @omiosomoy4706
    @omiosomoy47062 жыл бұрын

    this is a life saver

  • @azureliseraleighchocolatec6832
    @azureliseraleighchocolatec68322 жыл бұрын

    Great.

  • @rabiekhalifa1103
    @rabiekhalifa1103 Жыл бұрын

    Thank you a lot 💖

  • @SandeshMotoVlogs
    @SandeshMotoVlogs2 жыл бұрын

    I have only 1 word for u : GOAT 🐐 ( Greatest Of All Time)

  • @CodeExplained

    @CodeExplained

    2 жыл бұрын

    hahah thanks a lot ❤️

  • @Omid.Pishkar
    @Omid.Pishkar2 жыл бұрын

    Very nice... i like this video

  • @GabrielSilva-yk6kk
    @GabrielSilva-yk6kk Жыл бұрын

    thanks for sharing your knowledge

  • @CodeExplained

    @CodeExplained

    Жыл бұрын

    Glad to do so.

  • @sahedsumon8511
    @sahedsumon85112 жыл бұрын

    It's a really great explanation.

  • @CodeExplained

    @CodeExplained

    Жыл бұрын

    Glad you think so!

  • @plaguegames3556
    @plaguegames35562 жыл бұрын

    Great explanation

  • @CodeExplained

    @CodeExplained

    Жыл бұрын

    Glad you think so!

  • @universalworthy2169
    @universalworthy21692 жыл бұрын

    Wonderful live saver tutorial. Please do more vanilla js projects, like pagination, dictionary...

  • @CodeExplained

    @CodeExplained

    Жыл бұрын

    Happy to hear it was helpful, yes I will.

  • @krzysiekwarchal
    @krzysiekwarchal2 жыл бұрын

    Great Job. Is there a way to send the shopping bag to email when clicking proceed to checkout?

  • @olidhossen9785
    @olidhossen97852 жыл бұрын

    Nice

  • @charlesmwaniki1868
    @charlesmwaniki1868 Жыл бұрын

    perfect....thanks man

  • @CodeExplained

    @CodeExplained

    Жыл бұрын

    You're welcome!

  • @feliciatimmy9467
    @feliciatimmy94672 жыл бұрын

    you're a life saver bro

  • @CodeExplained

    @CodeExplained

    2 жыл бұрын

    Happy to hear that, thanks ❤️

  • @renesalvacion2452
    @renesalvacion2452 Жыл бұрын

    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

  • @user-fq8st9ot5p
    @user-fq8st9ot5p Жыл бұрын

    thanks so much

  • @amanpratap5547
    @amanpratap5547 Жыл бұрын

    Extremly Extremly Extremly..........................useful. Thanks for the content.

  • @CodeExplained

    @CodeExplained

    Жыл бұрын

    Glad it was helpful!

  • @jahjahtruth
    @jahjahtruth2 жыл бұрын

    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

    @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.

  • @essenc3189
    @essenc3189 Жыл бұрын

    veryy good tutorial , 10x

  • @march9698
    @march96982 жыл бұрын

    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

    @CodeExplained

    2 жыл бұрын

    Yeah I know, I didn't want to waste time on making it responsive, sorry.

  • @march9698

    @march9698

    2 жыл бұрын

    @@CodeExplained No need to be sorry, you did an amazing job.

  • @user-lj6is5kn8o
    @user-lj6is5kn8o2 жыл бұрын

    I wish you 1m subscribers!

  • @CodeExplained

    @CodeExplained

    2 жыл бұрын

    Thanks a lot ❤️

  • @vijayd5551
    @vijayd5551 Жыл бұрын

    lots of thanks... please share the next part for checkout cart.

  • @CodeExplained

    @CodeExplained

    Жыл бұрын

    Next part? What do you want for next part?

  • @sdfsdfsdffdsfsdfsd123
    @sdfsdfsdffdsfsdfsd123 Жыл бұрын

    thank you !!!!

  • @CodeExplained

    @CodeExplained

    Жыл бұрын

    You're welcome!

  • @Kevin-uf7yt
    @Kevin-uf7yt Жыл бұрын

    if i use json to store my data, what is the equivalent code of the function addToCart in 16:39 for it?

  • @alexanderson1193
    @alexanderson11932 жыл бұрын

    if I want to make a separate single product page what do I need to alter?

  • @aboodibajaman9975
    @aboodibajaman99752 жыл бұрын

    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

  • @yogapassion
    @yogapassion2 жыл бұрын

    I have been waiting more videos from you for a long time . Do you alright ?

  • @nataliabogach6580
    @nataliabogach65802 жыл бұрын

    How can you add product options like size and color ?

  • @codingislife6387
    @codingislife6387 Жыл бұрын

    Thank Sir.

  • @CodeExplained

    @CodeExplained

    Жыл бұрын

    You're welcome.

  • @zalisco1
    @zalisco12 жыл бұрын

    THANK YOU BROTHER

  • @CodeExplained

    @CodeExplained

    Жыл бұрын

    You are welcome

  • @charlesohlson4316
    @charlesohlson4316 Жыл бұрын

    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.

  • @sarvij9870
    @sarvij9870 Жыл бұрын

    Hi, best shopping cart tutorial, ty Sir. I have a question: min 38:50, instead of showing the price, i got NaN. Any solutions?

  • @darkNovaskar
    @darkNovaskar10 ай бұрын

    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?

  • @sivas4061
    @sivas40612 жыл бұрын

    What vs code theme you're using?

  • @mohanadgallab
    @mohanadgallab6 ай бұрын

    thank you alot for this ,,

  • @codewithharris
    @codewithharris Жыл бұрын

    Please when are you gonna add filter cards JavaScript tutorial. I have search every where but doesn't implement it without error

  • @lovemanga_forever
    @lovemanga_forever2 жыл бұрын

    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

    @CodeExplained

    Жыл бұрын

    I'll check it out!

  • @mybMee
    @mybMee2 жыл бұрын

    thanks 😊👍

  • @CodeExplained

    @CodeExplained

    2 жыл бұрын

    You're welcome.

  • @ifeomablessing9578
    @ifeomablessing9578 Жыл бұрын

    Awesome. However I need help. When I host my project on github, the images in the array are not displaying. I need help please

  • @eliasgrinwisplaatstultjes7857
    @eliasgrinwisplaatstultjes78572 жыл бұрын

    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

    @ifeomablessing9578

    Жыл бұрын

    Exactly!!!! I need help with this too.?

  • @aza7866
    @aza7866 Жыл бұрын

    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) :(

  • @tigerwalkcommunications7426
    @tigerwalkcommunications74262 жыл бұрын

    Please on your next video make a checkout page😌

  • @fatimakayy
    @fatimakayy Жыл бұрын

    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

    @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

    @fatimakayy

    Жыл бұрын

    @@CodeExplained thank you! I figured it out

  • @codingislife6387
    @codingislife6387 Жыл бұрын

    Nice Sir. Please Make More Project ... Please Please

  • @CodeExplained

    @CodeExplained

    Жыл бұрын

    Thanks, of course I will

  • @codingislife6387

    @codingislife6387

    Жыл бұрын

    Thank Sir.

  • @tahirzaman9441
    @tahirzaman94412 жыл бұрын

    Waiting for your new videos...➡️➡️➡️➡️➡️ Js projects

  • @shubhamjangid5936
    @shubhamjangid5936 Жыл бұрын

    how to render the cart items on a diffrent cart page ? IM STUCK HERE :(

  • @CodeExplained

    @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.

  • @Mindinmatrix
    @Mindinmatrix2 жыл бұрын

    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

    @CodeExplained

    Жыл бұрын

    Save the cart to the user's browser's local storage.

  • @Mindinmatrix

    @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!

  • @sagarraut797
    @sagarraut7972 жыл бұрын

    I want to add discount facility or buy one get free, how can I do that?

  • @CodeExplained

    @CodeExplained

    2 жыл бұрын

    Add new properties to the products, { ... discount : 20, free_product: 1 } and take those in mind when calculating the subtotal.

  • @expukpuk
    @expukpuk2 жыл бұрын

    Where is the link for your template in github?

  • @CodeExplained

    @CodeExplained

    2 жыл бұрын

    github.com/CodeExplainedRepo/shopping-cart-javascript

  • @andrewsokolovsky9127
    @andrewsokolovsky91272 жыл бұрын

    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

    @lidijajezova2025

    2 жыл бұрын

    "Here" it is where?

  • @MamamimPlodtook
    @MamamimPlodtook2 жыл бұрын

    Hi , i have try to follow code and i cannot manage changeNumberOfUnits because of onclick function.

  • @CodeExplained

    @CodeExplained

    Жыл бұрын

    How can I help you?

  • @callumspellium1516
    @callumspellium15162 жыл бұрын

    weres the chocolate and banna javscript?

  • @CodeExplained

    @CodeExplained

    2 жыл бұрын

    Coming Soon! Vanilla JS means Plain JS no framework.

  • @21398403
    @21398403 Жыл бұрын

    Thanks for the video and please add a New video with paypal button.

  • @Toast917
    @Toast917 Жыл бұрын

    helping me with my APCSP class 🫶🙏

  • @jowarnis
    @jowarnis2 жыл бұрын

    dude is using innerHTML to create elements.. I just cant.. terrible

  • @CodeExplained

    @CodeExplained

    Жыл бұрын

    hahah sorry