В настройки ТДС Корзины добавляем код после блока
-- // Добавление товара в корзину
/**
* Комплекты
* Начало >>
*/
$aAssoc = Core_Array::getRequest('addassoc');
if (count($aAssoc))
{
foreach($aAssoc as $assoc)
{
$oShop_Cart_Controller = Shop_Cart_Controller::instance();
$oShop_Cart_Controller
->shop_item_id($assoc)
->quantity(1)
->add();
}
}
/**
* << Конец
*/
Добавляем в макет Каталога скрипт:
/**
* Обработчик решения set-of-goods
*/
var lastCheck="";$(document).ready(function(){function t(){total=parseInt($("#mainprice").data("price")),$("select.associated option").each(function(){$(this).prop("selected")&&$(this).data("price")&&(total+=parseInt($(this).data("price")))}),$("input.associated").each(function(){$(this).prop("checked")&&(total+=parseInt($(this).data("price")))}),totalStr="",totalStr+=total,total=totalStr.replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1 "),$("#bz_price").val(total),$("#mainprice").html(total)}$("input[type='radio'].associated").click(function(){lastCheck=lastCheck==this?($(this).prop("checked",!$(this).prop("checked")),""):this}),$("input.associated").click(function(){t()}),$("select.associated").change(function(){t()}),$("input[type=radio].associated:checked").click(),t(),$("select.associated option:selected").click(),t(),jQuery.extend({kaddIntoCart:function(t,a,e,c){c=c||0;var i="";return $(".associated"+a).each(function(){$(this).prop("checked")&&$.clientRequest({path:t,data:{add:$(this).data("item"),count:1},callBack:function(){},context:$("#little_cart")})}),$("select.associated option").each(function(){$(this).prop("selected")&&(i+="&addassoc[]="+$(this).data("item"))}),c?$.bootstrapAddIntoCart(t,a+i,e):$.addIntoCart(t,a+i,e),!1}})});
var lastCheck = "";
$(document).ready(function() {
function t() {
total = parseInt($("#mainprice").data("price")), $("select.associated option").each(function() {
$(this).prop("selected") && $(this).data("price") && (total += parseInt($(this).data("price")))
}), $("input.associated").each(function() {
$(this).prop("checked") && (total += parseInt($(this).data("price")))
}), totalStr = "", totalStr += total, total = totalStr.replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1 "), $("#bz_price").val(total), $("#mainprice").html(total)
}
$("input[type='radio'].associated").click(function() {
lastCheck = lastCheck == this ? ($(this).prop("checked", !$(this).prop("checked")), "") : this
}), $("input.associated").click(function() {
t()
}), $("select.associated").change(function() {
t()
}), $("input[type=radio].associated:checked").click(), t(), $("select.associated option:selected").click(), t(), jQuery.extend({
kaddIntoCart: function(t, a, e, c) {
c = c || 0;
var i = "";
return $(".associated" + a).each(function() {
$(this).prop("checked") && $.clientRequest({
path: t,
data: {
add: $(this).data("item"),
count: 1
},
callBack: function() {},
context: $("#little_cart")
})
}), $("select.associated option").each(function() {
$(this).prop("selected") && (i += "&addassoc[]=" + $(this).data("item"))
}), c ? $.bootstrapAddIntoCart(t, a + i, e) : $.addIntoCart(t, a + i, e), !1
}
})
});
В XSL шаблон "КарточкаТовара" добавляем блок вывода комплектов
<!--
*
* Комплекты
* Начало >>
-->
<xsl:if test="count(associated/shop_item) > 0">
<div class="associated-block gifts-list clearfix">
<p class="h5 text-center red bold"><i class="fa fa-gift"></i> Выберите подарок: </p>
<div class="slider-similar-wrapper">
<div id="gifts" class="slick-slider">
<xsl:apply-templates select="associated/shop_item" mode="assoc"><xsl:sort select="sorting" data-type="number"/></xsl:apply-templates>
</div>
</div>
<span class="hr"></span>
</div>
</xsl:if>
<!--
* << Конец
-->