S
S
symply_rabbit2019-06-19 13:39:47
JavaScript
symply_rabbit, 2019-06-19 13:39:47

Which query shows a particular error in the script?

good afternoon!
wrote a script handler for deleting a product from the basket of pending goods

$CART_PRODUCT_ID=intval($_REQUEST['id']);




if (CSaleBasket::Delete($CART_PRODUCT_ID)) {
echo "успешно";
}
else {
echo "ошибка";
echo $CART_PRODUCT_ID;
}


That's where I display the "error" what text should I write to show what kind of error is there?
Thanks in advance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg Prilepa, 2019-06-20
@OAPrilepa

It's better to use the new API to add to cart:

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

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

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

Source: https://mrcappuccino.ru/blog/post/work-with-basket...

S
serginhold, 2019-06-19
@serginhold

https://dev.1c-bitrix.ru/api_help/main/reference/c...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question