A
A
Andrey Kharitonov2019-04-30 13:20:59
1C-Bitrix
Andrey Kharitonov, 2019-04-30 13:20:59

How does Add2BasketByProductID add a product to the cart?

there is a code

\Add2BasketByProductID(6006, 1, array(), array(
                    array(  "NAME" => "Доступ",
                            "CODE" => "PERMISSION",
                            "VALUE" => ""
                    )
                ));

method should add item to cart. Not added. Please tell me why the products are added in the browser, and the Add2BasketByProductID function is executed through the console - but the product is not added to the basket.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Proger, 2019-04-30
@freekirill

if (CModule::IncludeModule("sale") && CModule::IncludeModule("catalog")) { 
    //$PRODUCT_ID  - ID товара
    //$QUANTITY - кол-во товара    
    Add2BasketByProductID( $PRODUCT_ID, $QUANTITY ); 
}else { echo "Не подключены модули"; }

Here is a sample code

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question