Creating an Ecommerce Shopping Cart

Hi guys!

I am currently working on an ecommerce project for my web portfolio and decided to add a shopping cart. I imagined that Javascript would be the best language for the task. Entries in the shopping cart were manually added (screenshot attached).
My initial thoughts were to:

  • Create an empty array and assign it to “cart” variable
  • Create an “item” class and use items from an inventory list to create instances of the “item” class
  • Create for loop to append objects to cart array
  • Append cart to div in HTML

My question is, what is the best way to create a shopping cart? Your feedback would be appreciated. Thanks.

1 Like

Hi Dennis,

Yes JavaScript would be the best to do this. Are you using a specific Framework or Vanilla JavaScript? Did you already finish your project?

I am in a process to do a shopping website, just using pure JavaScript, would be great if we can share knowledge.

Thank you
Discord: elvss1#7056
Elvis.

Hi Elvis,

I’m excited to hear about your project!

Actually, I used Bootstrap to cut down on time.

I took a break from my project to fill in my knowledge gaps in JS. I’m gonna be working on it again pretty soon. I’ll keep you posted.

Thank you!