Answer the question
In order to leave comments, you need to log in
Can't see the item in the cart?
On the site, when viewing the product in detail, there is a comparison with the basket, and if the product is already in the basket, then a message appears under the buy button, that the product is already there.
All processing goes in two files, the first and main one is result_modifier
, here is its code
$dbBasketItems = CSaleBasket::GetList(
array(
"NAME" => "ASC",
"ID" => "ASC"
),
array(
"FUSER_ID" => CSaleBasket::GetBasketUserID(),
"LID" => SITE_ID,
"PRODUCT_ID" => $arResult['ID'], //ID of the current product
),
false,
false,
array("PRODUCT_ID"
) );
while ($arItemsBasket = $dbBasketItems->Fetch()) {
$itInBasket = $arItemsBasket['PRODUCT_ID'];
}
$arResult['T1'] = $itInBasket;
And the second one in the temlate file
<?if(isset($arResult['T1'])):?> The
product is already in the cart. About
<?endif;?>
But no message is displayed. When running through the debugger, all properties even $dbBasketItems contain false and null.
Can anyone suggest what could be the problem or error?
Answer the question
In order to leave comments, you need to log in
Usually, components are cached . Cash is common to everyone, but the basket is individual.
Such tasks are solved using the OnEndBufferContent event.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question