A
A
andrew0808882020-12-21 01:00:15
PHP
andrew080888, 2020-12-21 01:00:15

How to add more than one product to Bitrix24 webhook lead using crm.lead.productrows.set ???

The code below adds a product to the lead, the problem is that it only adds one product. If there are 2 items to transfer, then only one last item is added.

$queryUrl = $this->bitrix_url'/crm.lead.productrows.set.json';
        $queryData = http_build_query(array(
        'id' => $leadID, 
        'rows' => array(
            array(
        "PRODUCT_ID" => $id,
        "PRICE" => $price,
        "QUANTITY" => $qty,
        )),
        ));
        
        $curl = curl_init();
        curl_setopt_array($curl, array(
        CURLOPT_SSL_VERIFYPEER => 0,
        CURLOPT_POST => 1,
        CURLOPT_HEADER => 0,
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_URL => $queryUrl,
        CURLOPT_POSTFIELDS => $queryData,
        ));
       
        $result = curl_exec($curl);
        curl_close($curl);
        $result = json_decode($result, 1);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dim, 2020-12-21
@Dee3

Give what code you add 2 products.
inside should be something like

'rows' => array(
array(
        "PRODUCT_ID" => $id,
        "PRICE" => $price,
        "QUANTITY" => $qty,
        ),

array(
        "PRODUCT_ID" => $id2,
        "PRICE" => $price2,
        "QUANTITY" => $qty2,
        )
),

It should be taken into account that the commodity items that existed before the method call will be replaced by new ones. After saving, the amount of the lead will be recalculated.
In other words, the positions are completely overwritten if you suddenly try to add another one to the existing ones.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question