Answer the question
In order to leave comments, you need to log in
How to display a description of a Bitrix trading offer, instead of a description of the main product?
Good afternoon!
The question seems simple, it seems not.
Bitrix catalog, typical.
There is a product. It has a description. It is displayed when the item is opened.
The product has trade offers (color, size) and also has its own description in the "detailed description" for each TP.
Is it possible to do something so that when choosing a TP, what would the description change? Similarly, how the characteristics change
Answer the question
In order to leave comments, you need to log in
On the example of a standard template:
1. In index.php of your catalog, check that DETAIL_TEXT is marked in the DETAIL_OFFERS_FIELD_CODE parameter 2. Template.php
file
- at the very beginning there is an array of $itemIds add to it
- find where the detailed text is displayed (data-value reference ="description" and $arResult['DETAIL_TEXT']) and wrap it in a div
'DESCRIPTION' => $mainId.'_description',
<div id="<?=$itemIds['DESCRIPTION']?>"><?=$arResult['DETAIL_TEXT_TYPE'] === 'html' ? $arResult['DETAIL_TEXT'] : '<p>'.$arResult['DETAIL_TEXT'].'</p>';?></div>
if ($haveOffers)
{
//...................
foreach ($arResult['JS_OFFERS'] as $ind => &$jsOffer)
{
$jsOffer['DETAIL_TEXT'] = (isset($arResult['OFFERS'][$ind]['DETAIL_TEXT']) && $arResult['OFFERS'][$ind]['DETAIL_TEXT'] ? $arResult['OFFERS'][$ind]['DETAIL_TEXT'] : $arResult['DETAIL_TEXT']);
changeInfo: function()
this.setPrice();
this.setDetailText(this.offers[index].DETAIL_TEXT);
setDetailText: function(text) {
if(typeof(this.visual.DESCRIPTION) !== 'undefined') {
BX.adjust(BX(this.visual.DESCRIPTION), {html: text});
}
},
Of course you can, display detailed descriptions in hidden divs, override the sku switch click callback and show the content you need
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question