M
M
Maxim2014-11-14 22:01:46
JavaScript
Maxim, 2014-11-14 22:01:46

javascript cart function

Can you please tell me or give me a tip how to make cart functions in native js? The biggest difficulty is that you need to parse the data of the product under which you clicked "order" (cost, name, etc.), so how to determine what exactly under a particular product was clicked order and forbid it from being added to the cart again? Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2014-11-14
@might

What if I want 2 identical items?
Well, in general, check the array with goods for the presence of the same ones, if there is one in the basket, then we add it to the quantity 1, and do not add it as a new position

R
Rsa97, 2014-11-14
@Rsa97

The most primitive way

<button onclick="addItem(код_товара, название_товара, цена);">+</button>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question