как поставить условие , что если предложение одно, то показывать его, если больше 1, то показывать ссылку на страницу товара
Код |
---|
<?if(is_array($arElement["OFFERS"]) && !empty($arElement["OFFERS"])):?>
<div class="catalog-item-offers">
<?$i=0;?>
<?if($i<=1):?>
<?foreach($arElement["OFFERS"] as $arOffer):?>
<div class="catalog-detail-line"></div>
<div class="table-offers">
<?if(!empty($arParams["OFFERS_FIELD_CODE"]) || !empty($arOffer["DISPLAY_PROPERTIES"])):?>
<table cellspacing="0">
<?foreach($arParams["OFFERS_FIELD_CODE"] as $field_code):?>
<tr><td class="catalog-item-offers-field"><span><?echo GetMessage("IBLOCK_FIELD_".$field_code)?>:</span></td><td><?
echo $arOffer[$field_code];?></td></tr>
<?endforeach;?>
<?foreach($arOffer["DISPLAY_PROPERTIES"] as $pid=>$arProperty):?>
<tr><td class="catalog-item-offers-prop"><span><?=$arProperty["NAME"]?>:</td><td><?
if(is_array($arProperty["DISPLAY_VALUE"]))
echo implode(" / ", $arProperty["DISPLAY_VALUE"]);
else
echo $arProperty["DISPLAY_VALUE"];?></td></tr>
<?endforeach?>
</table>
<?endif;?>
<?foreach($arOffer["PRICES"] as $code=>$arPrice):?>
<?if($arPrice["CAN_ACCESS"]):?>
<div class="catalog-item-price" itemprop = "offers" itemscope itemtype = "http://schema.org/Offer">
<?if($arPrice["DISCOUNT_VALUE"] < $arPrice["VALUE"]):?>
<span class="catalog-item-price" itemprop = "price"><?=$arPrice["PRINT_DISCOUNT_VALUE"]?></span> <s><span itemprop = "price"><?=$arPrice["PRINT_VALUE"]?></span></s>
<?else:?>
<span class="catalog-item-price" itemprop = "price"><?=$arPrice["PRINT_VALUE"]?></span>
<?endif?>
<?endif;?>
<?endforeach;?>
<?if($arOffer["CAN_BUY"]):?>
<a href="<?echo $arOffer["ADD_URL"]?>" class="catalog-item-buy<?/*catalog-item-in-the-cart*/?>" rel="nofollow" on click="return addToCart(this, 'catalog_list_image_<?=$arElement['ID']?>', 'list', '<?=GetMessage("CATALOG_IN_CART")?>');" id="catalog_add2cart_link_ofrs_<?=$arOffer['ID']?>"><?echo GetMessage("CATALOG_ADD")?></a>
<?elseif(count($arResult["PRICES"]) > 0):?>
<span class="catalog-item-not-available"><?=GetMessage("CATALOG_NOT_AVAILABLE")?></span>
<?endif?></div></div>
<?endforeach;?>
<?elseif ($i > 2):?></div><a href="<?=$arElement["DETAIL_PAGE_URL"]?>">Variant</a></div>
<?endif;?>
</div>
<?else:?>
<?foreach($arElement["PRICES"] as $code=>$arPrice):
if($arPrice["CAN_ACCESS"]):
?>
<div class="catalog-item-price" itemprop = "offers" itemscope itemtype = "http://schema.org/Offer">
<?if($arPrice["DISCOUNT_VALUE"] < $arPrice["VALUE"]):?>
<span class="catalog-item-price" itemprop = "price"><?=$arPrice["PRINT_DISCOUNT_VALUE"]?></span> <s><span itemprop = "price"><?=$arPrice["PRINT_VALUE"]?></span></s>
<?else:?>
<span class="catalog-item-price" itemprop = "price"><?=$arPrice["PRINT_VALUE"]?></span>
<?endif;?>
</div>
<?
endif;
endforeach;
?>
<?endif?>
</div>
</div>
<?if(empty($arElement["OFFERS"])):?>
<div class="catalog-item-links">
<!--noindex-->
<?if ($arElement['CAN_BUY']):?>
<a href="<?echo $arElement["ADD_URL"]?>" class="catalog-item-buy<?/*catalog-item-in-the-cart*/?>" rel="nofollow" on click="return addToCart(this, 'catalog_list_image_<?=$arElement['ID']?>', 'list', '<?=GetMessage("CATALOG_IN_CART")?>');" id="catalog_add2cart_link_<?=$arElement['ID']?>"><?echo GetMessage("CATALOG_ADD")?></a>
<?elseif (count($arResult["PRICES"]) > 0):?>
<span class="catalog-item-not-available"><?=GetMessage('CATALOG_NOT_AVAILABLE')?></span>
<?endif;?>
<?if($arParams["DISPLAY_COMPARE"]):?>
<a href="<?echo $arElement["COMPARE_URL"]?>" class="catalog-item-compare" on click="return addToCompare(this, '<?=GetMessage("CATALOG_IN_COMPARE")?>');" rel="nofollow" id="catalog_add2compare_link_<?=$arElement['ID']?>"><?echo GetMessage("CATALOG_COMPARE")?></a>
<?endif;?>
<!--noindex--> |