Skip to content

Conversation

@AlexPL2201
Copy link
Owner

No description provided.

this.addEventHandlers();
},

addProduct() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

генерацию разметки лучше сделать через шаблонные строки.


addToCart(product) {
const productChecked = this.cart.find(productCheck => productCheck.id == product.id);
if (productChecked == undefined) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (!productChecked)

Comment on lines +73 to +74
product.count = 1;
this.cart.push(product);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

product.count = 1;
this.cart.push({...product, count: 1});

if (!event.target.classList.contains('btn')) return;
const productId = event.target.dataset.id;
const product = this.products.find(product => product.id == productId);
myCart.addToCart(product);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

завязка на глобальную переменную myCart

this.showCart();
},

showCart() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

генерацию разметки лучше делать через шаблонные строки

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants