Y
Y
Yastr2018-07-19 13:28:44
1C-Bitrix
Yastr, 2018-07-19 13:28:44

How to check in catalog.section if at least one of the offers is available for purchase?

Good afternoon.
In the catalog.element template, checking for the availability of an item for purchase is defined as

if (isset($arResult['OFFERS']) && !empty($arResult['OFFERS'])) {
  $canBuy = $arResult['OFFERS'][$arResult['OFFERS_SELECTED']]['CAN_BUY'];
}
else {
  $canBuy = $arResult['CAN_BUY'];
}
echo $canBuy; // 1 или ничего

in the section template found the only check on canbuy
$canBuy = $arItem['JS_OFFERS'][$arItem['OFFERS_SELECTED']]['CAN_BUY'];
I don't quite understand why, but I don't think it works at all.
please tell me how to check if at least one of the sales offers in catalog.section is available for purchase?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yastr, 2018-07-21
@Yastr

<?
$canBuy = false;
foreach($arItem['OFFERS'] as $arOffer){
  if(isset($arOffer['MIN_PRICE']) && is_array($arOffer['MIN_PRICE']) && $arOffer['MIN_PRICE']['DISCOUNT_VALUE'] > 0){
    $canBuy = true;
  }
}
if($canBuy){
  ?>доступно<?
} 
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question