Articles
Latest
More
Newsletter Sponsorship Discord About
Sign up for our Newsletter
The video for this lesson is currently being updated, please read the transcript instead.
Build Your First Vue.js App > Lesson 15

Adding products to the cart

The next thing we want to do is get the addToCart method to do its proper job.

It'll need to do two things: firstly, it'll need to update the total value, and secondly, it'll need to push products to the cart array so they're ready to be displayed.

We'll deal with updating the total first. Our product objects don't have a price property yet, so let's add that now. We'll give each one a price of 9.99.

products: [
  { title: "Product 1", id: 1, price: 9.99 },

Back to course page

Click to load comments...

Articles
  • Latest
Newsletter
  • Join
  • Sponsorship
More
  • Discord
  • Vue.js jobs
  • About

Vue.js Developers © 2021. View our privacy policy .

  • RSS
  • |
  • Atom