This is an old revision of the document!
На странице товара вместе с основным товаром покупателю предлагается купить дополнительные товары и услуги. Такие товары можно добавить к основному установив флажок. При этом происходит пересчет основной цены. При нажатии на кнопку добавления товара в корзину, в корзину попадают сразу все выбранные товары.
<!– Шаблон для комплекта товаров –>
<xsl:template match="associated/shop_item">
<label>
<xsl:choose>
<xsl:when test="property_value[tag_name='radio']/value = 1">
<input type="radio" price="{price}" name="item_radio" item_id="{@id}" value="{@id}" class="associated{../../@id} associated"><xsl:if test="property_value[tag_name='default']/value = 1"><xsl:attribute name="checked">checked</xsl:attribute></xsl:if></input>
</xsl:when>
<xsl:otherwise>
<xsl:if test="position() != last()"><xsl:attribute name="class">hr</xsl:attribute></xsl:if>
<input type="checkbox" price="{price}" item_id="{@id}" name="item_{@id}" value="{@id}" class="associated{../../@id} associated"><xsl:if test="property_value[tag_name='default']/value = 1"><xsl:attribute name="checked">checked</xsl:attribute></xsl:if></input>
</xsl:otherwise>
</xsl:choose>
</label>
</xsl:template>
<xsl:if test="count(associated/shop_item) > 0">
<xsl:apply-templates select="associated/shop_item"><xsl:sort select="sorting" data-type="number"/></xsl:apply-templates>
<span class="hr"></span>
</div>
</xsl:if>''
- Подгоняем вывод под текущий сайт. Блоку с текущей ценой задаем ''id="mainprice"'', а также атрибут ''data-price="{format-number(price, '#####0', 'my')}"''
- Обработчик добавления в корзину заменяем с $.addIntoCart на $.kaddIntoCart
- Добавляем товарам доп. свойства. Эти свойства нужны для управления комплектом.
* "Радиокнопка" с tag_name='radio'
* "По умолчанию" с tag_name='default'