S
S
Stopy2017-07-31 14:45:02
PHP
Stopy, 2017-07-31 14:45:02

Why aren't the properties of the cart item being set or displayed?

I am attaching the source code of the script:

require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
CModule::IncludeModule("sale");
CModule::IncludeModule("catalog");

// Чистим корзину
CSaleBasket::DeleteAll(CSaleBasket::GetBasketUserID());

// Добавляем 1 продукт в корзину со свойствами в 3-ем аргументе
$id = Add2BasketByProductID(
    317, 2,
    [
        ["NAME" => "Цвет", "CODE" => "CLR", "VALUE" => "красный", "SORT" => 5],
        ["NAME" => "Размер", "VALUE" => "25"]
    ]
);

// Получаем элементы корзины
$dbBasketItems = CSaleBasket::GetList(
    [],
    [ "FUSER_ID" => CSaleBasket::GetBasketUserID(), "LID" => SITE_ID, "ID" => $id],
    false, false, []
);
while ($arItems = $dbBasketItems->Fetch())
{
    $arItems["PROPS"] = [];

    $db_res_prop = CSaleBasket::GetPropsList( array(), array("BASKET_ID" => $arItems['ID']) );
    while ($ar_res_prop = $db_res_prop->Fetch()) $arItems["PROPS"][] = $ar_res_prop; // Пусто, нет свойств которые были добавлены

    echo "<pre>";
    print_r($arItems);
    echo "</pre>";
}

Output code:
Array
(
    [ID] => 7836
    [LID] => s1
    [FUSER_ID] => 117453
    [ORDER_ID] => 
    [PRODUCT_ID] => 317
    [PRODUCT_PRICE_ID] => 281
    [NAME] => ДЕТОКС ПРОГРАММА
    [PRICE] => 3200.0000
    [CURRENCY] => RUB
    [BASE_PRICE] => 3200.0000
    [VAT_INCLUDED] => Y
    [DATE_INSERT] => Bitrix\Main\Type\DateTime Object
        (
            [value:protected] => DateTime Object
                (
                    [date] => 2017-07-31 14:42:37.000000
                    [timezone_type] => 3
                    [timezone] => Europe/Moscow
                )

        )

    [DATE_UPDATE] => Bitrix\Main\Type\DateTime Object
        (
            [value:protected] => DateTime Object
                (
                    [date] => 2017-07-31 14:42:37.000000
                    [timezone_type] => 3
                    [timezone] => Europe/Moscow
                )

        )

    [WEIGHT] => 0.00
    [QUANTITY] => 2
    [DELAY] => N
    [CAN_BUY] => Y
    [MODULE] => catalog
    [PRODUCT_PROVIDER_CLASS] => CCatalogProductProvider
    [NOTES] => Розничная цена
    [DETAIL_PAGE_URL] => /catalog/detail.php?ID=317
    [DISCOUNT_PRICE] => 0.0000
    [CATALOG_XML_ID] => clothes_s1
    [PRODUCT_XML_ID] => 317
    [DISCOUNT_NAME] => 
    [DISCOUNT_VALUE] => 0
    [DISCOUNT_COUPON] => 
    [VAT_RATE] => 0.0000
    [SUBSCRIBE] => N
    [RESERVED] => N
    [RESERVE_QUANTITY] => 
    [BARCODE_MULTI] => N
    [CUSTOM_PRICE] => N
    [DIMENSIONS] => a:3:{s:5:"WIDTH";s:1:"0";s:6:"HEIGHT";s:1:"0";s:6:"LENGTH";s:1:"0";}
    [TYPE] => 
    [SET_PARENT_ID] => 
    [MEASURE_CODE] => 796
    [MEASURE_NAME] => шт
    [CALLBACK_FUNC] => 
    [ORDER_CALLBACK_FUNC] => 
    [CANCEL_CALLBACK_FUNC] => 
    [PAY_CALLBACK_FUNC] => 
    [RECOMMENDATION] => 
    [SORT] => 100
    [PROPS] => Array
        (
        )

)

Already tormented, in advance, thanks, Jedi.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artyom Luchnikov, 2017-07-31
@Stopy

The code works, I checked it on my site. Here you already need to look specifically at your copy of the product. Or contact Bitrix technical support.

A
Andrey Nikolaev, 2017-07-31
@gromdron

Shouldn't they be passed in the 4th parameter: Add2BasketByProductID($PRODUCT_ID, $QUANTITY = 1, ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question