Answer the question
In order to leave comments, you need to log in
How to fix output condition from php array?
while ($arItems = $dbBasketItems->Fetch())
{
$arBasketItems[] = $arItems;
//print ($arItems[PRODUCT_ID]); выведет без пробелов 12804 12805 12806 20910
if ($arCurOffer['ID'] == $arItems[PRODUCT_ID])
echo 'Уже в корзине'; else echo 'Купить';
}
BuyBuyBuyAlready in the cart
Buy
Already in cart
Answer the question
In order to leave comments, you need to log in
You basically have a list of goods. Given that this is Bitrix, we will not change the logic:
$inBasket = false;
while ($arItems = $dbBasketItems->Fetch())
{
$arBasketItems[] = $arItems;
//print ($arItems[PRODUCT_ID]); выведет без пробелов 12804 12805 12806 20910
if ($arCurOffer['ID'] == $arItems['PRODUCT_ID']){ // Пожалуйста, ключ массива заключайте в кавычки, пишите правильно.
$inBasket = true;
}
}
echo $inBasket ? 'Уже в Корзине' : 'Купить';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question