A
A
Alexander2020-07-13 12:40:15
1C-Bitrix
Alexander, 2020-07-13 12:40:15

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

2 answer(s)
P
PetrPo, 2020-07-13
@kikher

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>

- find somewhere at the end there is
if ($haveOffers)
{
//...................
  foreach ($arResult['JS_OFFERS'] as $ind => &$jsOffer)
  {

inside the cycle, add (the code below is approximate, such as if the TP has a description, then we take it, if not, then from the main product, you can correct it as you need)
$jsOffer['DETAIL_TEXT'] = (isset($arResult['OFFERS'][$ind]['DETAIL_TEXT']) && $arResult['OFFERS'][$ind]['DETAIL_TEXT'] ? $arResult['OFFERS'][$ind]['DETAIL_TEXT'] : $arResult['DETAIL_TEXT']);

3. File script.js
- nadi function - in this function near the end, where the data is set through functions, such as add your function, for example like this
changeInfo: function()
this.setPrice();
this.setDetailText(this.offers[index].DETAIL_TEXT);

- well, right after the changeInfo function, describe your function
setDetailText: function(text) {
  if(typeof(this.visual.DESCRIPTION) !== 'undefined') {
    BX.adjust(BX(this.visual.DESCRIPTION), {html: text});
  }
},

A
Alexey Emelyanov, 2020-07-13
@babarun

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 question

Ask a Question

731 491 924 answers to any question