Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Responsive ecommerce-product-page

Anouerβ€’ 510

@AnouerMokrane

Desktop design screenshot for the E-commerce product page coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
3intermediate
View challenge

Design comparison


SolutionDesign

Solution retrospective


Hello, I have problems with the cart any help please.

Community feedback

Jo89 πŸ˜ˆβ€’ 380

@AhmadYousif89

Posted

Hi Anouer πŸ‘‹

Your solution looks good πŸ‘, I see that you have a problem with the cart logic, I will just point out to the issues that I see and possible fixes if I can but you will have to provide more info about your problem.

  • the add to car counter start initially with 1 that supposedly means that you don't want the user to enter a value less than that but I can clearly decrease the counter to 0 πŸ€·β€β™‚οΈ so I would prevent that or just start with 0 as initial value.

  • after decreasing the counter to 0 I can still add item with qty = 0 to the cart you should prevent that by adding some if condition like

if (counter === 0 ) return
// rest of your code
  • adding an item doesn't increase the qty but rather pushes the item again to the array, again you should only add the item once with qty =1 if it's the first time or increment qty by 1 or the counter value if the item already exist in the cart so you need to check if the item exist or not with some code like
const exItem = state.cart.find(item => item.id === payload.id)
if (exItem) {
  // increment the qty here
} else {
  // just set the qty to equal 1
}
  • after adding multiple item to the cart I can only remove the first one (and this issue relates to the previous one so if you fix the previous issue I think this one will also be fixed)

  • I think the cart container has some fixed width and height and that is not ideal for the inner elements to fit properly inside so try adding min-width and min-height instead (if you actually need to)

and that's some of what I have noticed so far but overall nice work. if you have any questions don't hesitate to ask πŸ‘

Keep Coding πŸ‘Š

Marked as helpful

1

Anouerβ€’ 510

@AnouerMokrane

Posted

@AhmadYousif89 Thanks that's what i need.

0
Jo89 πŸ˜ˆβ€’ 380

@AhmadYousif89

Posted

@AnouerMokrane

anytime Anouer 😊 can you mark the comment as helpful if you find it to be so, thanks πŸ‘

1

Please log in to post a comment

Log in with GitHub
Discord logo

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord