A
A
Andrey Bely2020-11-27 20:49:36
1C-Bitrix
Andrey Bely, 2020-11-27 20:49:36

How to add related products on click on checkbox?

Good evening!
The customer wants to display related products for each product himself and so that they can be added by clicking on the checkbox:
5fc13c0c26b02189639243.jpeg
How best to implement?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PetrPo, 2020-11-30
@PetrPo

catalog components do not support deleting an item from the cart.
If you look that catalog.section and catalog.element are inherited from the \Bitix\Iblock\Component\Base class, which contains the code for adding a product to the cart by the get parameter ADD2BASKET and there are no methods associated with deletion.
I can’t solve it with simple manipulations, I can describe the procedure:
1. In the component template that will display your products in the script.js file, you need to write your own deletion logic, just a few lines of code are enough, but you will need to understand this script. The point is to send ajax to your file
2. In the ajax file you write the logic for deleting the product - google it, there is nothing complicated
3. A difficult thing - when loading, you need to find out the product is already in the basket or not, in order to show the desired button, you need to take into account that the product may be with trade offers
4. You need to synchronize the whole thing with a small basket, in the same script.js, when adding there is such a synchronization of the goods in the basket
Well, the most unpleasant moment is the consideration of the extraordinary behavior of the user:
1. I go to the goods1 and put 5 units in the basket
2. I go to product 2, product 1 is linked to this product and this product is already in the cart, I click delete, which will delete all 5 units of the product, do you think it’s normal to give this opportunity to the user? I'm not talking about the fact that he will start to be stupid when he goes to the basket and does not see the product there1, and even from a marketing point of view, you give him an extra opportunity to refuse to buy

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question