R
R
run1822021-04-08 11:26:17
1C-Bitrix
run182, 2021-04-08 11:26:17

How to add additional services to the cart along with the product?

There are types of services:
- installation of a washing machine
- hang a TV on a bracket
- add. warranty (1-3 years)

For example, a client added 2 products to the cart:
- Phone
- TV
How to add services (chosen by the user) to the cart? You can add separate products, but then, if the client removes the TV from the basket, the "hang up the TV" service will remain in it, which is not logical.

Does Bitrix have functionality to implement this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaliy Vayti, 2021-04-10
@run182

This is where I did something similar. Implemented by adding individual products.
Add the main product to the cart, when adding additional (services), indicate in the description which product this service is added to. When you remove an item from your shopping cart, remove additional items as well.

Bitrix\Main\Loader::includeModule("catalog");

$fields = [
    'PRODUCT_ID' => 98, // ID товара, обязательно
    'QUANTITY' => 1, // количество, обязательно
    'PROPS' => [
        ['NAME' => 'Test prop', 'CODE' => 'TEST_PROP', 'VALUE' => 'test value'],
    ],

];
$r = Bitrix\Catalog\Product\Basket::addProduct($fields);
if (!$r->isSuccess()) {
    var_dump($r->getErrorMessages());
}

In the example that I indicated, the deletion of the add-on is not visible now. services when deleting goods, but it was they themselves who later converted the basket to a standard one and did not save this functionality ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question