|
Всем привет. Решил обновить всю платформу битрикса. После обновления перестали показываться торговые предложения в карточке товара. Мне так кажется что не до конца отрабатывает скрипт, но могу ошибаться. Нужна срочная помощь. Вот офф сайт http://www.krasnaya-zvezda.ru/catalog/detskie_krovatki/uralochka_s_742/ на котором все работает. А вот тестовый сайт где не работает http://detskie-tovary.ru/catalog/detskie_krovatki/uralochka_s_742/ . Вот сам скрипт: Код |
---|
JCCatalogElement = function (arParams)
{
this.productType = 0;
this.showQuantity = true;
this.showAbsent = true;
this.checkQuantity = false;
this.maxQuantity = 0;
this.stepQuantity = 1;
this.isDblQuantity = false;
this.canBuy = true;
this.canSubscription = true;
this.showOldPrice = false;
this.showPercent = false;
this.showSkuProps = false;
this.showOfferGroup = false;
this.visual = {
ID: '',
PICT_ID: '',
QUANTITY_ID: '',
QUANTITY_UP_ID: '',
QUANTITY_DOWN_ID: '',
PRICE_ID: '',
OLD_PRICE_ID: '',
DISCOUNT_VALUE_ID: '',
DISCOUNT_PERC_ID: '',
OFFER_GROUP: ''
};
this.product = {
checkQuantity: false,
maxQuantity: 0,
stepQuantity: 1,
isDblQuantity: false,
canBuy: true,
canSubscription: true,
name: '',
pict: {},
id: 0
};
this.ajaxPath = '';
this.mess = {};
this.defaultPict = {
preview: null,
detail: null
};
this.offers = [];
this.offerNum = 0;
this.treeProps = [];
this.obTreeRows = [];
this.showCount = [];
this.showStart = [];
this.selectedValues = {};
this.sliders = [];
this.obProduct = null;
this.obQuantity = null;
this.obQuantityUp = null;
this.obQuantityDown = null;
this.obPict = null;
this.obPrice = {
price: null,
full: null,
discount: null,
percent: null
};
this.obTree = null;
this.obBuyBtn = null;
this.obSkuProps = null;
this.obSlider = null;
this.obMeasure = null;
this.obQuantityLimit = {
all: null,
value: null
};
this.obZoom = {
cont: null,
pict: null
};
this.enableZoom = false;
this.showZoom = false;
this.errorCode = 0;
if ('object' == typeof(arParams))
{
this.productType = parseInt(arParams.PRODUCT_TYPE);
this.showQuantity = arParams.SHOW_QUANTITY;
if (!!arParams.SHOW_DISCOUNT_PERCENT)
this.showPercent = true;
if (!!arParams.SHOW_OLD_PRICE)
this.showOldPrice = true;
if (!!arParams.SHOW_SKU_PROPS)
this.showSkuProps = true;
if (!!arParams.OFFER_GROUP)
this.showOfferGroup = true;
this.visual = arParams.VISUAL;
this.ajaxPath = arParams.AJAX_PATH;
if (!!arParams.MESS)
this.mess = arParams.MESS;
switch (this.productType)
{
case 1://product
case 2://set
if (!!arParams.PRODUCT && 'object' == typeof(arParams.PRODUCT))
{
if (this.showQuantity)
{
this.product.checkQuantity = arParams.PRODUCT.CHECK_QUANTITY;
this.product.isDblQuantity = arParams.PRODUCT.QUANTITY_FLOAT;
if (this.product.checkQuantity)
this.product.maxQuantity = (this.product.isDblQuantity
? parseFloat(arParams.PRODUCT.MAX_QUANTITY)
: parseInt(arParams.PRODUCT.MAX_QUANTITY)
);
this.product.stepQuantity = (this.product.isDblQuantity
? parseFloat(arParams.PRODUCT.STEP_QUANTITY)
: parseInt(arParams.PRODUCT.STEP_QUANTITY)
);
this.checkQuantity = this.product.checkQuantity;
this.isDblQuantity = this.product.isDblQuantity;
this.maxQuantity = this.product.maxQuantity;
this.stepQuantity = this.product.stepQuantity;
}
this.product.canBuy = arParams.PRODUCT.CAN_BUY;
this.product.canSubscription = arParams.PRODUCT.SUBSCRIPTION;
this.product.buyUrl = arParams.PRODUCT.BUY_URL;
this.canBuy = this.product.canBuy;
this.canSubscription = this.product.canSubscription;
this.product.name = arParams.PRODUCT.NAME;
this.product.pict = arParams.PRODUCT.PICT;
this.product.id = arParams.PRODUCT.ID;
}
else
{
this.errorCode = -1;
}
break;
case 3://sku
if (!!arParams.OFFERS && BX.type.isArray(arParams.OFFERS))
{
this.offers = arParams.OFFERS;
this.offerNum = 0;
if (!!arParams.OFFER_SELECTED)
this.offerNum = parseInt(arParams.OFFER_SELECTED);
if (isNaN(this.offerNum))
this.offerNum = 0;
if (!!arParams.TREE_PROPS)
this.treeProps = arParams.TREE_PROPS;
if (!!arParams.DEFAULT_PICTURE)
{
this.defaultPict.preview = arParams.DEFAULT_PICTURE.PREVIEW_PICTIRE;
this.defaultPict.detail = arParams.DEFAULT_PICTURE.DETAIL_PICTURE;
}
}
else
{
this.errorCode = -1;
}
break;
default:
this.errorCode = -1;
}
}
if (0 == this.errorCode)
{
BX.ready(BX.delegate(this.Init,this));
}
};
JCCatalogElement.prototype.Init = function()
{
var i = 0;
var j = 0;
this.obProduct = BX(this.visual.ID);
if (!this.obProduct)
this.errorCode = -1;
this.obPict = BX(this.visual.PICT_ID);
if (!this.obPict)
this.errorCode = -2;
this.obPrice.price = BX(this.visual.PRICE_ID);
if (!this.obPrice.price)
{
this.errorCode = -16;
}
else
{
if (!!this.visual.OLD_PRICE_ID)
{
this.obPrice.full = BX(this.visual.OLD_PRICE_ID);
if (!this.obPrice.full)
this.errorCode = -17;
}
if (!!this.visual.DISCOUNT_VALUE_ID)
{
this.obPrice.discount = BX(this.visual.DISCOUNT_VALUE_ID);
if (!this.obPrice.discount)
this.errorCode = -18;
}
if (this.showPercent)
{
if (!!this.visual.DISCOUNT_PERC_ID)
{
this.obPrice.percent = BX(this.visual.DISCOUNT_PERC_ID);
if (!this.obPrice.percent)
this.errorCode = -19;
}
}
}
if (this.showQuantity && !!this.visual.QUANTITY_ID)
{
this.obQuantity = BX(this.visual.QUANTITY_ID);
if (!this.obQuantity)
this.errorCode = -32;
if (!!this.visual.QUANTITY_UP_ID)
{
this.obQuantityUp = BX(this.visual.QUANTITY_UP_ID);
if (!this.obQuantityUp)
this.errorCode = -64;
}
if (!!this.visual.QUANTITY_DOWN_ID)
{
this.obQuantityDown = BX(this.visual.QUANTITY_DOWN_ID);
if (!this.obQuantityDown)
this.errorCode = -128;
}
}
if (3 == this.productType)
{
if (!!this.visual.TREE_ID)
{
this.obTree = BX(this.visual.TREE_ID);
if (!this.obTree)
this.errorCode = -256;
var strPrefix = this.visual.TREE_ITEM_ID;
for (i = 0; i < this.treeProps.length; i++)
{
this.obTreeRows[i] = {
LEFT: BX(strPrefix+this.treeProps[i].ID+'_left'),
RIGHT: BX(strPrefix+this.treeProps[i].ID+'_right'),
LIST: BX(strPrefix+this.treeProps[i].ID+'_list'),
CONT: BX(strPrefix+this.treeProps[i].ID+'_cont')
};
if (!this.obTreeRows[i].LEFT || !this.obTreeRows[i].RIGHT || !this.obTreeRows[i].LIST || !this.obTreeRows[i].CONT)
{
this.errorCode = -512;
break;
}
}
}
if (!!this.visual.QUANTITY_MEASURE)
{
this.obMeasure = BX(this.visual.QUANTITY_MEASURE);
}
if (!!this.visual.QUANTITY_LIMIT)
{
this.obQuantityLimit.all = BX(this.visual.QUANTITY_LIMIT);
if (!!this.obQuantityLimit.all)
{
this.obQuantityLimit.value = BX.findChild(this.obQuantityLimit.all, {tagName: 'span'}, false, false);
if (!this.obQuantityLimit.value)
this.obQuantityLimit.all = null;
}
}
}
if (!!this.visual.BIG_SLIDER_ID)
{
this.obSlider = BX(this.visual.BIG_SLIDER_ID);
if (!this.obSlider)
{
this.errorCode = -1024;
}
}
if (!!this.visual.BUY_ID)
{
this.obBuyBtn = BX(this.visual.BUY_ID);
if (!this.obBuyBtn)
{
}
}
if (this.showSkuProps)
{
if (!!this.visual.DISPLAY_PROP_DIV)
{
this.obSkuProps = BX(this.visual.DISPLAY_PROP_DIV);
}
}
/* if (!!this.visual.ZOOM_DIV && !!this.visual.ZOOM_PICT)
{
this.obZoom.cont = BX(this.visual.ZOOM_DIV);
this.obZoom.pict = BX(this.visual.ZOOM_PICT);
if (!this.obZoom.cont || !this.obZoom.pict)
{
}
else
{
}
} */
if (0 == this.errorCode)
{
if (this.showQuantity)
{
BX.bind(this.obQuantityUp, 'click', BX.delegate(this.QuantityUp, this));
BX.bind(this.obQuantityDown, 'click', BX.delegate(this.QuantityDown, this));
BX.bind(this.obQuantity, 'change', BX.delegate(this.QuantityChange, this));
}
switch (this.productType)
{
case 1://product
break;
case 3://sku
var TreeItems = BX.findChildren(this.obTree, {tagName: 'li'}, true);
if (!!TreeItems && 0 < TreeItems.length)
{
for (i = 0; i < TreeItems.length; i++)
{
BX.bind(TreeItems[i], 'click', BX.delegate(function(e){this.SelectOfferProp(e); }, this));
}
}
for (i = 0; i < this.obTreeRows.length; i++)
{
BX.bind(this.obTreeRows[i].LEFT, 'click', BX.delegate(function(e){this.RowLeft(e); }, this));
BX.bind(this.obTreeRows[i].RIGHT, 'click', BX.delegate(function(e){this.RowRight(e); }, this));
}
for (i = 0; i < this.offers.length; i++)
{
if (0 == this.offers[i].SLIDER_COUNT)
{
this.sliders[i] = {
COUNT: this.offers[i].SLIDER_COUNT,
ID: ''
};
}
else
{
for (j = 0; j < this.offers[i].SLIDER.length; j++)
{
this.offers[i].SLIDER[j].WIDTH = parseInt(this.offers[i].SLIDER[j].WIDTH);
this.offers[i].SLIDER[j].HEIGHT = parseInt(this.offers[i].SLIDER[j].HEIGHT);
}
this.sliders[i] = {
COUNT: this.offers[i].SLIDER_COUNT,
OFFER_ID: this.offers[i].ID,
ID: this.visual.SLIDER_CONT_OF_ID+this.offers[i].ID,
CONT: BX(this.visual.SLIDER_CONT_OF_ID+this.offers[i].ID),
LIST: BX(this.visual.SLIDER_LIST_OF_ID+this.offers[i].ID),
LEFT: BX(this.visual.SLIDER_LEFT_OF_ID+this.offers[i].ID),
RIGHT: BX(this.visual.SLIDER_RIGHT_OF_ID+this.offers[i].ID),
START: 0
};
var SliderImgs = BX.findChildren(this.sliders[i].LIST, {tagName: 'li'}, true);
if (!!SliderImgs && 0 < SliderImgs.length)
{
for (j = 0; j < SliderImgs.length; j++)
{
BX.bind(SliderImgs[j], 'click', BX.delegate(function(e){this.SelectSliderImg(e); }, this));
}
}
if (!!this.sliders[i].LEFT)
BX.bind(this.sliders[i].LEFT, 'click', BX.delegate(function(e){this.SliderRowLeft(e); }, this));
if (!!this.sliders[i].RIGHT)
BX.bind(this.sliders[i].RIGHT, 'click', BX.delegate(function(e){this.SliderRowRight(e); }, this));
}
}
this.SetCurrent();
break;
}
if (!!this.obBuyBtn)
BX.bind(this.obBuyBtn, 'click', BX.delegate(this.Basket, this));
}
};
JCCatalogElement.prototype.SliderRowLeft = function(e)
{
if (!e) e = window.event;
var target = BX.proxy_context;
if (!!target && target.hasAttribute('data-value'))
{
var strValue = target.getAttribute('data-value');
var index = -1;
for (var i = 0; i < this.sliders.length; i++)
{
if (this.sliders[i].OFFER_ID == strValue)
{
index = i;
break;
}
}
if (-1 < index && 5 < this.sliders[index].COUNT)
{
if ((5 - this.sliders[index].START) < this.sliders[index].COUNT)
{
this.sliders[index].START--;
BX.adjust(this.sliders[index].LIST, { style: { marginLeft: this.sliders[index].START*20+'%' }});
}
}
}
};
JCCatalogElement.prototype.SliderRowRight = function(e)
{
if (!e) e = window.event;
var target = BX.proxy_context;
if (!!target && target.hasAttribute('data-value'))
{
var strValue = target.getAttribute('data-value');
var index = -1;
for (var i = 0; i < this.sliders.length; i++)
{
if (this.sliders[i].OFFER_ID == strValue)
{
index = i;
break;
}
}
if (-1 < index && 5 < this.sliders[index].COUNT)
{
if (0 > this.sliders[index].START)
{
this.sliders[index].START++;
BX.adjust(this.sliders[index].LIST, { style: { marginLeft: this.sliders[index].START*20+'%' }});
}
}
}
};
JCCatalogElement.prototype.SelectSliderImg = function(e)
{
if (!e) e = window.event;
var target = BX.proxy_context;
if (!!target && target.hasAttribute('data-value'))
{
var strValue = target.getAttribute('data-value');
var arItem = strValue.split('_');
this.SetMainPict(arItem[0], arItem[1]);
}
};
JCCatalogElement.prototype.SetMainPict = function(intSlider, intPict)
{
var index = -1;
var indexPict = -1;
var i = 0;
var j = 0;
for (i = 0; i < this.offers.length; i++)
{
if (intSlider == this.offers[i].ID)
{
index = i;
break;
}
}
if (-1 < index)
{
if (0 < this.offers[index].SLIDER_COUNT)
{
for (j = 0; j < this.offers[index].SLIDER.length; j++)
{
if (intPict == this.offers[index].SLIDER[j].ID)
{
indexPict = j;
break;
}
}
if (-1 < indexPict)
{
if (!!this.obPict && !!this.offers[index].SLIDER[indexPict])
{
BX.adjust(
this.obPict,
{
props: {
src: this.offers[index].SLIDER[indexPict].SRC,
/* className: (this.offers[index].SLIDER[indexPict].WIDTH > this.offers[index].SLIDER[indexPict].HEIGHT ? 'landscape' : 'portrait') */
className: ''
}
}
);
}
var RowItems = BX.findChildren(this.sliders[index].LIST, {tagName: 'li'}, false);
if (!!RowItems && 0 < RowItems.length)
{
var strValue = intSlider+'_'+intPict;
for (i = 0; i < RowItems.length; i++)
{
value = RowItems[i].getAttribute('data-value');
if (value == strValue)
BX.addClass(RowItems[i], 'bx_active');
else
BX.removeClass(RowItems[i], 'bx_active');
}
}
}
}
}
};
JCCatalogElement.prototype.SetMainPictFromItem = function(index)
{
if (!!this.obPict)
{
var boolSet = false;
var obNewPicture = {};
if (!!this.offers[index])
{
if (!!this.offers[index].DETAIL_PICTURE)
{
obNewPict = this.offers[index].DETAIL_PICTURE;
boolSet = true;
}
else if (!!this.offers[index].PREVIEW_PICTURE)
{
obNewPict = this.offers[index].PREVIEW_PICTURE;
boolSet = true;
}
}
if (!boolSet)
{
if (!!this.defaultPict.detail)
{
obNewPict = this.defaultPict.detail;
boolSet = true;
}
else if (!!this.defaultPict.preview)
{
obNewPict = this.defaultPict.preview;
boolSet = true;
}
}
if (boolSet)
{
BX.adjust(
this.obPict,
{
props: {
src: obNewPict.SRC,
className: (obNewPict.WIDTH > obNewPict.HEIGHT ? 'landscape' : 'portrait')
}
}
);
}
}
};
JCCatalogElement.prototype.QuantityUp = function()
{
var curValue = 0;
var boolSet = true;
if (0 == this.errorCode && this.showQuantity)
{
curValue = (
this.isDblQuantity
? parseFloat(this.obQuantity.value)
: parseInt(this.obQuantity.value)
);
if (!isNaN(curValue))
{
curValue += this.stepQuantity;
if (this.checkQuantity)
{
if (curValue > this.maxQuantity)
boolSet = false;
}
if (boolSet)
{
this.obQuantity.value = curValue;
}
}
}
};
JCCatalogElement.prototype.QuantityDown = function()
{
var curValue = 0;
var boolSet = true;
if (0 == this.errorCode && this.showQuantity)
{
curValue = (
this.isDblQuantity
? parseFloat(this.obQuantity.value)
: parseInt(this.obQuantity.value)
);
if (!isNaN(curValue))
{
curValue -= this.stepQuantity;
if (curValue < this.stepQuantity)
boolSet = false;
if (boolSet)
{
this.obQuantity.value = curValue;
}
}
}
};
JCCatalogElement.prototype.QuantityChange = function()
{
var curValue = 0;
var boolSet = true;
if (0 == this.errorCode && this.showQuantity)
{
curValue = (
this.isDblQuantity
? parseFloat(this.obQuantity.value)
: parseInt(this.obQuantity.value)
);
if (!isNaN(curValue))
{
if (this.checkQuantity)
{
if (curValue > this.maxQuantity)
{
boolSet = false;
curValue = this.maxQuantity;
}
else if (curValue < this.stepQuantity)
{
boolSet = false;
curValue = this.stepQuantity;
}
}
if (!boolSet)
{
this.obQuantity.value = curValue;
//
}
}
else
{
this.obQuantity.value = this.stepQuantity;
//
}
}
};
JCCatalogElement.prototype.QuantitySet = function(index)
{
if (0 == this.errorCode)
{
this.canBuy = this.offers[index].CAN_BUY;
if (this.showQuantity)
{
this.isDblQuantity = this.offers[index].QUANTITY_FLOAT;
this.checkQuantity = this.offers[index].CHECK_QUANTITY;
this.maxQuantity = (this.isDblQuantity
? parseFloat(this.offers[index].MAX_QUANTITY)
: parseInt(this.offers[index].MAX_QUANTITY)
);
this.stepQuantity = (this.isDblQuantity
? parseFloat(this.offers[index].STEP_QUANTITY)
: parseInt(this.offers[index].STEP_QUANTITY)
);
this.obQuantity.value = this.stepQuantity;
if (!!this.obMeasure)
{
if (!!this.offers[index].MEASURE)
{
BX.adjust(this.obMeasure, { html : this.offers[index].MEASURE});
}
else
{
BX.adjust(this.obMeasure, { html : ''});
}
}
if (!!this.obQuantityLimit.all)
{
if (!this.checkQuantity)
{
BX.adjust(this.obQuantityLimit.value, { html: '' });
BX.adjust(this.obQuantityLimit.all, { style: {display: 'none'} });
}
else
{
var strLimit = this.offers[index].MAX_QUANTITY;
if (!!this.offers[index].MEASURE)
strLimit += (' '+this.offers[index].MEASURE);
BX.adjust(this.obQuantityLimit.value, { html: strLimit});
BX.adjust(this.obQuantityLimit.all, { style: {display: ''} });
}
}
}
}
};
JCCatalogElement.prototype.SelectOfferProp = function(e)
{
if (!e) e = window.event;
var target = BX.proxy_context;
if (!!target && target.hasAttribute('data-treevalue'))
{
var strTreeValue = target.getAttribute('data-treevalue');
var arTreeItem = strTreeValue.split('_');
this.SearchOfferPropIndex(arTreeItem[0], arTreeItem[1]);
var RowItems = BX.findChildren(target.parentNode, {tagName: 'li'}, false);
if (!!RowItems && 0 < RowItems.length)
{
for (i = 0; i < RowItems.length; i++)
{
BX.removeClass(RowItems[i], 'bx_active');
}
}
BX.addClass(target, 'bx_active');
}
};
JCCatalogElement.prototype.SearchOfferPropIndex = function(strPropID, strPropValue)
{
var index = -1;
for (var i = 0; i < this.treeProps.length; i++)
{
if (this.treeProps[i].ID == strPropID)
{
index = i;
break;
}
}
if (-1 < index)
{
var arFilter = {};
for (i = 0; i < index; i++)
{
var strName = 'PROP_'+this.treeProps[i].ID;
arFilter[strName] = this.selectedValues[strName];
}
var strName = 'PROP_'+this.treeProps[index].ID;
arFilter[strName] = strPropValue;
for (i = index+1; i < this.treeProps.length; i++)
{
strName = 'PROP_'+this.treeProps[i].ID;
var arShowValues = this.GetRowValues(arFilter, strName);
if (!arShowValues)
break;
if (this.showAbsent)
{
var arCanBuyValues = [];
var tmpFilter = [];
tmpFilter = BX.clone(arFilter, true);
for (var j = 0; j < arShowValues.length; j++)
{
tmpFilter[strName] = arShowValues[j];
if (this.GetCanBuy(tmpFilter))
arCanBuyValues[arCanBuyValues.length] = arShowValues[j];
}
}
else
{
var arCanBuyValues = arShowValues;
}
if (!!this.selectedValues[strName] && BX.util.in_array(this.selectedValues[strName], arCanBuyValues))
arFilter[strName] = this.selectedValues[strName];
else
arFilter[strName] = arCanBuyValues[0];
this.UpdateRow(i, arFilter[strName], arShowValues, arCanBuyValues);
}
this.selectedValues = arFilter;
this.ChangeInfo();
}
};
JCCatalogElement.prototype.RowLeft = function(e)
{
if (!e) e = window.event;
var target = BX.proxy_context;
if (!!target && target.hasAttribute('data-treevalue'))
{
var strTreeValue = target.getAttribute('data-treevalue');
var index = -1;
for (var i = 0; i < this.treeProps.length; i++)
{
if (this.treeProps[i].ID == strTreeValue)
{
index = i;
break;
}
}
if (-1 < index && 5 < this.showCount[index])
{
if ((5 - this.showStart[index]) < this.showCount[index])
{
this.showStart[index]--;
BX.adjust(this.obTreeRows[index].LIST, { style: { marginLeft: this.showStart[index]*20+'%' }});
}
}
}
};
JCCatalogElement.prototype.RowRight = function(e)
{
if (!e) e = window.event;
var target = BX.proxy_context;
if (!!target && target.hasAttribute('data-treevalue'))
{
var strTreeValue = target.getAttribute('data-treevalue');
var index = -1;
for (var i = 0; i < this.treeProps.length; i++)
{
if (this.treeProps[i].ID == strTreeValue)
{
index = i;
break;
}
}
if (-1 < index && 5 < this.showCount[index])
{
if (0 > this.showStart[index])
{
this.showStart[index]++;
BX.adjust(this.obTreeRows[index].LIST, { style: { marginLeft: this.showStart[index]*20+'%' }});
}
}
}
};
JCCatalogElement.prototype.UpdateRow = function(intNumber, activeID, showID, canBuyID)
{
var i = 0;
var value;
var countShow = 0;
var strNewLen = '';
if (-1 < intNumber && intNumber < this.obTreeRows.length)
{
var RowItems = BX.findChildren(this.obTreeRows[intNumber].LIST, {tagName: 'li'}, false);
if (!!RowItems && 0 < RowItems.length)
{
countShow = showID.length;
strNewLen = (5 < countShow ? (100/countShow)+'%' : '20%');
obData = {
props: { className: '' },
style: {
width: strNewLen
}
};
if ('E' == this.treeProps[intNumber].TYPE)
obData.style.paddingTop = strNewLen;
for (i = 0; i < RowItems.length; i++)
{
value = RowItems[i].getAttribute('data-onevalue');
if (BX.util.in_array(value, canBuyID))
{
if (value == activeID)
obData.props.className = 'bx_active';
else
obData.props.className = '';
}
else
{
if (value == activeID)
obData.props.className = 'bx_active bx_missing';
else
obData.props.className = 'bx_missing';
}
if (BX.util.in_array(value, showID))
obData.style.display = '';
else
obData.style.display = 'none';
BX.adjust(RowItems[i], obData);
}
obData = {
style: {
width: (5 < countShow ? 20*countShow : 100)+'%',
marginLeft: '0%'
}
};
BX.adjust(this.obTreeRows[intNumber].LIST, obData);
if ('E' == this.treeProps[intNumber].TYPE)
BX.adjust(this.obTreeRows[intNumber].CONT, {props: {className: (5 < countShow ? 'bx_item_detail_scu full' : 'bx_item_detail_scu')}});
else
BX.adjust(this.obTreeRows[intNumber].CONT, {props: {className: (5 < countShow ? 'bx_item_detail_size full' : 'bx_item_detail_size')}});
if (5 < countShow)
{
BX.adjust(this.obTreeRows[intNumber].LEFT, {style: {display: ''}});
BX.adjust(this.obTreeRows[intNumber].RIGHT, {style: {display: ''}});
}
else
{
BX.adjust(this.obTreeRows[intNumber].LEFT, {style: {display: 'none'}});
BX.adjust(this.obTreeRows[intNumber].RIGHT, {style: {display: 'none'}});
}
this.showCount[intNumber] = countShow;
this.showStart[intNumber] = 0;
}
}
};
JCCatalogElement.prototype.GetRowValues = function(arFilter, index)
{
var arValues = [];
var boolSearch = false;
if (0 == arFilter.length)
{
for (var i = 0; i < this.offers.length; i++)
{
if (!BX.util.in_array(this.offers[i].TREE[index], arValues))
arValues[arValues.length] = this.offers[i].TREE[index];
}
boolSearch = true;
}
else
{
for (var i = 0; i < this.offers.length; i++)
{
var boolOneSearch = true;
for (var j in arFilter)
{
if (arFilter[j] != this.offers[i].TREE[j])
{
boolOneSearch = false;
break;
}
}
if (boolOneSearch)
{
if (!BX.util.in_array(this.offers[i].TREE[index], arValues))
arValues[arValues.length] = this.offers[i].TREE[index];
boolSearch = true;
}
}
}
return (boolSearch ? arValues : false);
};
JCCatalogElement.prototype.GetCanBuy = function(arFilter)
{
var boolSearch = false;
for (var i = 0; i < this.offers.length; i++)
{
var boolOneSearch = true;
for (var j in arFilter)
{
if (arFilter[j] != this.offers[i].TREE[j])
{
boolOneSearch = false;
break;
}
}
if (boolOneSearch)
{
if (this.offers[i].CAN_BUY)
{
boolSearch = true;
break;
}
}
}
return boolSearch;
};
JCCatalogElement.prototype.SetCurrent = function()
{
var arFilter = {};
var current = this.offers[this.offerNum].TREE;
for (var i = 0; i < this.treeProps.length; i++)
{
var strName = 'PROP_'+this.treeProps[i].ID;
var arShowValues = this.GetRowValues(arFilter, strName);
if (!arShowValues)
break;
if (BX.util.in_array(current[strName], arShowValues))
{
arFilter[strName] = current[strName];
}
else
{
arFilter[strName] = arShowValues[0];
this.offerNum = 0;
}
if (this.showAbsent)
{
var arCanBuyValues = [];
var tmpFilter = [];
tmpFilter = BX.clone(arFilter, true);
for (var j = 0; j < arShowValues.length; j++)
{
tmpFilter[strName] = arShowValues[j];
if (this.GetCanBuy(tmpFilter))
arCanBuyValues[arCanBuyValues.length] = arShowValues[j];
}
}
else
{
var arCanBuyValues = arShowValues;
}
this.UpdateRow(i, arFilter[strName], arShowValues, arCanBuyValues);
}
this.selectedValues = arFilter;
this.ChangeInfo();
};
JCCatalogElement.prototype.ChangeInfo = function()
{
var index = -1;
for (var i = 0; i < this.offers.length; i++)
{
var boolOneSearch = true;
for (var j in this.selectedValues)
{
if (this.selectedValues[j] != this.offers[i].TREE[j])
{
boolOneSearch = false;
break;
}
}
if (boolOneSearch)
{
index = i;
break;
}
}
if (-1 < index)
{
if (!!this.obPrice.price)
{
BX.adjust(this.obPrice.price, {html: this.offers[index].PRICE.PRINT_DISCOUNT_VALUE});
if (this.offers[index].PRICE.DISCOUNT_VALUE != this.offers[index].PRICE.VALUE)
{
if (this.showOldPrice)
{
if (!!this.obPrice.full)
BX.adjust(this.obPrice.full, {style: {display: ''}, html: this.offers[index].PRICE.PRINT_VALUE});
if (!!this.obPrice.discount)
BX.adjust(this.obPrice.discount, {style: {display: ''}, html: this.offers[index].PRICE.PRINT_DISCOUNT_DIFF});
}
if (this.showPercent)
{
if (!!this.obPrice.percent)
BX.adjust(this.obPrice.percent, {style: {display: ''}, html: this.offers[index].PRICE.DISCOUNT_DIFF_PERCENT+'%'});
}
}
else
{
if (this.showOldPrice)
{
if (!!this.obPrice.full)
BX.adjust(this.obPrice.full, {style: {display: 'none'}, html: ''});
if (!!this.obPrice.discount)
BX.adjust(this.obPrice.discount, {style: {display: 'none'}, html: ''});
}
if (this.showPercent)
{
if (!!this.obPrice.percent)
BX.adjust(this.obPrice.percent, {style: {display: 'none'}, html: ''});
}
}
}
for (i = 0; i < this.offers.length; i++)
{
if (this.showOfferGroup && this.offers[i].OFFER_GROUP)
{
if (i != index)
{
BX.adjust(BX(this.visual.OFFER_GROUP+this.offers[i].ID), { style: {display: 'none'} });
}
}
if ('' == this.sliders[i].ID)
continue;
if (i == index)
{
this.sliders[i].START = 0;
BX.adjust(this.sliders[i].LIST, {style: { marginLeft: '0%' }});
BX.adjust(this.sliders[i].CONT, {style: { display: ''}});
}
else
{
BX.adjust(this.sliders[i].CONT, {style: { display: 'none'}});
}
}
if (this.showOfferGroup && this.offers[index].OFFER_GROUP)
{
BX.adjust(BX(this.visual.OFFER_GROUP+this.offers[index].ID), { style: {display: ''} });
}
if (0 < this.offers[index].SLIDER_COUNT)
{
this.SetMainPict(this.offers[index].ID, this.offers[index].SLIDER[0].ID);
}
else
{
this.SetMainPictFromItem(index);
}
if (this.showSkuProps && !!this.obSkuProps)
{
if (0 == this.offers[index].DISPLAY_PROPERTIES.length)
{
BX.adjust(this.obSkuProps, {style: {display: 'none'}, html: ''});
}
else
{
BX.adjust(this.obSkuProps, {style: {display: ''}, html: this.offers[index].DISPLAY_PROPERTIES});
}
}
if (this.showQuantity)
{
this.QuantitySet(this.offerNum);
}
this.offerNum = index;
BX.onCustomEvent('onCatalogStoreProductChange', [this.offers[this.offerNum].ID]);
}
};
JCCatalogElement.prototype.Basket = function()
{
if (!this.canBuy)
return;
switch (this.productType)
{
case 1://product
var strBasket = this.product.buyUrl;
if (this.showQuantity)
strBasket += '&quantity='+this.obQuantity.value;
location.href=strBasket;
break;
case 3://sku
var strBasket = this.offers[this.offerNum].BUY_URL;
if (this.showQuantity)
strBasket += '&quantity='+this.obQuantity.value;
location.href=strBasket;
break;
default:
return;
}
};
JCCatalogElement.prototype.ShowBasketPopup = function(arResult)
{
var strContent = '';
if ('object' == typeof(arResult))
{
if ('OK' == arResult.STATUS)
{
strName = '';
strPict = '';
switch(this.productType)
{
case 1://
strName = this.product.name;
strPict = this.product.pict.SRC;
break;
case 3:
strName = this.offers[this.offerNum].NAME;
strPict = this.offers[this.offerNum].PICT.SRC;
break;
}
strContent = '<p>'+BX.message('ADD_TO_BASKET_OK')+'</p>';
strContent += '<img src="'+strPict+'" height="130"><p>'+strName+'</p>';
}
else
{
}
}
else
{
}
var popup = BX.PopupWindowManager.create('CatalogSectionBasket'+this.visual.ID, null, {
autoHide: false,
// zIndex: 0,
offsetLeft: 0,
offsetTop: 0,
overlay : true,
draggable: {restrict:true},
closeByEsc: true,
closeIcon: { right : "12px", top : "10px"},
content: '' +
'<div style="width:300px;text-align: center;padding-top:5px; margin-bottom: 10px;">' +
strContent+
'<a class="bx_bt_blue bx_medium" href="'+BX.message("setButtonBuyUrl")+'"><span class="bx_icon_cart"></span><span>'+BX.message("setButtonBuyName")+'</span></a>'+
'</div>'
});
popup.show();
};
JCCatalogElementZoom = function(arParams)
{
};
JCCatalogElementZoom.prototype.Init = function()
{
};
JCCatalogElementZoom.prototype.SetPict = function(arPict)
{
};
JCCatalogElementZoom.prototype.Show = function(e)
{
}; |
А вот сам template.php где все должно собраться: Код |
---|
<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
$strMainID = $this->GetEditAreaId($arResult['ID']);
$arItemIDs = array(
'ID' => $strMainID,
'PICT' => $strMainID.'_pict',
'DISCOUNT_PICT_ID' => $strMainID.'_dsc_pict',
'STICKER_ID' => $strMainID.'_stricker',
'BIG_SLIDER_ID' => $strMainID.'_big_slider',
'SLIDER_CONT_ID' => $strMainID.'_slider_cont',
'SLIDER_LIST' => $strMainID.'_slider_list',
'SLIDER_LEFT' => $strMainID.'_slider_left',
'SLIDER_RIGHT' => $strMainID.'_slider_right',
'OLD_PRICE' => $strMainID.'_old_price',
'PRICE' => $strMainID.'_price',
'DISCOUNT_PRICE' => $strMainID.'_price_discount',
'SLIDER_CONT_OF_ID' => $strMainID.'_slider_cont_',
'SLIDER_LIST_OF_ID' => $strMainID.'_slider_list_',
'SLIDER_LEFT_OF_ID' => $strMainID.'_slider_left_',
'SLIDER_RIGHT_OF_ID' => $strMainID.'_slider_right_',
'QUANTITY' => $strMainID.'_quantity',
'QUANTITY_DOWN' => $strMainID.'_quant_down',
'QUANTITY_UP' => $strMainID.'_quant_up',
'QUANTITY_MEASURE' => $strMainID.'_quant_measure',
'QUANTITY_LIMIT' => $strMainID.'_quant_limit',
'BUY_LINK' => $strMainID.'_buy_link',
'ADD_BASKET_LINK' => $strMainID.'_add_basket_link',
'COMPARE_LINK' => $strMainID.'_compare_link',
'PROP' => $strMainID.'_prop_',
'PROP_DIV' => $strMainID.'_skudiv',
'DISPLAY_PROP_DIV' => $strMainID.'_sku_prop',
'OFFER_GROUP' => $strMainID.'_set_group_',
'ZOOM_DIV' => $strMainID.'_zoom_cont',
'ZOOM_PICT' => $strMainID.'_zoom_pict'
);
$strObName = 'ob'.preg_replace("/[^a-zA-Z0-9_]/i", "x", $strMainID);
$arGroupdProp = Array();
foreach($arResult["PROPERTIES"] as $codes => $arPrp){
if($arPrp["HINT"]!=""){
$arGroupdProp[$arPrp["HINT"]][$codes] = $arPrp;
}
}
?>
<section class="product">
<sc ript type="text/javascript">
var offer = <?=json_encode($arResult['offers'][0])?>;
var gallery_elements = [
<?
if (!isset($arResult['offers']) || empty($arResult['offers']))
{
?>{name: '', background: '', current: true, id:<?=$arResult["ID"]?>, photo: [<?
foreach ($arResult['MORE_PHOTO'] as &$arOnePhoto)
{
$files = CFile::ResizeImageGet($arOnePhoto["ID"], array('width'=>102, 'height'=>102), BX_RESIZE_IMAGE_PROPORTIONAL, false);
$filem = CFile::ResizeImageGet($arOnePhoto["ID"], array('width'=>506, 'height'=>506), BX_RESIZE_IMAGE_PROPORTIONAL, false);
?>
{small: '<?=$files["src"]?>', medium: '<?=$filem["src"]?>', large: '<?=CFile::GetPath($arOnePhoto["ID"])?>'},
<?
}
unset($arOnePhoto);
}else{
$current = true;
foreach ($arResult['OFFERS'] as $key => $arOneOffer)
{
$price = explode('.', $arOneOffer["MIN_PRICE"]["PRINT_DISCOUNT_VALUE"]);
?>
{name: '<?=$arOneOffer["PROPERTIES"]["COLOR"]["VALUE_ENUM"]?>', title: '<?=$arOneOffer['NAME']?>', background: '#<?=$arOneOffer["PROPERTIES"]["COLOR"]["VALUE_XML_ID"]?>', current: <?if($current){ $current=false; ?>true<?}else{?>false<?}?>, id:<?=$arOneOffer["ID"]?>, price:'<?=$price[0]?>', oldprice:'<?=$arOneOffer["MIN_PRICE"]["PRINT_VALUE"]?>', photo: [
<?
foreach ($arOneOffer['MORE_PHOTO'] as &$arOnePhoto)
{
$files = CFile::ResizeImageGet($arOnePhoto["ID"], array('width'=>102, 'height'=>102), BX_RESIZE_IMAGE_PROPORTIONAL, false);
$filem = CFile::ResizeImageGet($arOnePhoto["ID"], array('width'=>506, 'height'=>506), BX_RESIZE_IMAGE_PROPORTIONAL, false);
?>
{small: '<?=$files["src"]?>', medium: '<?=$filem["src"]?>', large: '<?=CFile::GetPath($arOnePhoto["ID"])?>'},
<?
}
?>]},<?
}
unset($arOnePhoto);
}
?>
];
</sc ript>
<div class="content-container">
<div class="left">
<div class="product__largeImage">
<div class="top">
<div><img /></div>
</div>
<div class="bottom">
<div><img /></div>
</div>
</div>
<div class="product__imagePreviews"></div>
<div class="product__hidden"></div>
<div class="product__description">
<p><?=$arResult['DETAIL_TEXT']?></p>
</div>
<?global $arrDopFilter;
$arrDopFilter["ID"]=$arResult['PROPERTIES']["OTHER_PRODUCT"]["VALUE"];
?>
<?$APPLICATION->IncludeComponent(
"bitrix:catalog.section",
"other",
Array(
"TEMPLATE_THEME" => "blue",
"PRODUCT_DISPLAY_MODE" => "N",
"ADD_PICT_PROP" => "-",
"LABEL_PROP" => "-",
"PRODUCT_SUBSCRIPTION" => "N",
"SHOW_DISCOUNT_PERCENT" => "N",
"SHOW_OLD_PRICE" => "N",
"ADD_TO_BASKET_ACTION" => "ADD",
"SHOW_CLOSE_POPUP" => "N",
"MESS_BTN_BUY" => "Купить",
"MESS_BTN_ADD_TO_BASKET" => "В корзину",
"MESS_BTN_SUBSCRIBE" => "Подписаться",
"MESS_BTN_COMPARE" => "Сравнить",
"MESS_BTN_DETAIL" => "Подробнее",
"MESS_NOT_AVAILABLE" => "Нет в наличии",
"AJAX_MODE" => "N",
"IBLOCK_TYPE" => "maxicosi",
"IBLOCK_ID" => "11",
"SECTION_ID" => $arResult['IBLOCK_SECTION_ID'],
"SECTION_CODE" => "",
"SECTION_USER_FIELDS" => array(),
"ELEMENT_SORT_FIELD" => "sort",
"ELEMENT_SORT_ORDER" => "asc",
"ELEMENT_SORT_FIELD2" => "id",
"ELEMENT_SORT_ORDER2" => "desc",
"FILTER_NAME" => "arrDopFilter",
"INCLUDE_SUBSECTIONS" => "Y",
"SHOW_ALL_WO_SECTION" => "N",
"SECTION_URL" => "",
"DETAIL_URL" => "",
"SECTION_ID_VARIABLE" => "SECTION_ID",
"SET_TITLE" => "N",
"SET_BROWSER_TITLE" => "N",
"BROWSER_TITLE" => "-",
"SET_META_KEYWORDS" => "N",
"META_KEYWORDS" => "-",
"SET_META_DESCRIPTION" => "N",
"META_DESCRIPTION" => "-",
"ADD_SECTIONS_CHAIN" => "N",
"DISPLAY_COMPARE" => "N",
"SET_STATUS_404" => "N",
"PAGE_ELEMENT_COUNT" => "30",
"LINE_ELEMENT_COUNT" => "3",
"PROPERTY_CODE" => array(),
"OFFERS_FIELD_CODE" => array("ID"),
"OFFERS_PROPERTY_CODE" => array(),
"OFFERS_SORT_FIELD" => "sort",
"OFFERS_SORT_ORDER" => "asc",
"OFFERS_SORT_FIELD2" => "id",
"OFFERS_SORT_ORDER2" => "desc",
"OFFERS_LIMIT" => "5",
"PRICE_CODE" => array("BASE"),
"USE_PRICE_COUNT" => "N",
"SHOW_PRICE_COUNT" => "1",
"PRICE_VAT_INCLUDE" => "Y",
"BASKET_URL" => "/personal/basket.php",
"ACTION_VARIABLE" => "action",
"PRODUCT_ID_VARIABLE" => "id",
"USE_PRODUCT_QUANTITY" => "N",
"PRODUCT_QUANTITY_VARIABLE" => "quantity",
"ADD_PROPERTIES_TO_BASKET" => "Y",
"PRODUCT_PROPS_VARIABLE" => "prop",
"PARTIAL_PRODUCT_PROPERTIES" => "N",
"PRODUCT_PROPERTIES" => array(),
"CACHE_TYPE" => "A",
"CACHE_TIME" => "36000000",
"CACHE_FILTER" => "N",
"CACHE_GROUPS" => "Y",
"PAGER_TEMPLATE" => ".default",
"DISPLAY_TOP_PAGER" => "N",
"DISPLAY_BOTTOM_PAGER" => "N",
"PAGER_TITLE" => "Товары",
"PAGER_SHOW_ALWAYS" => "Y",
"PAGER_DESC_NUMBERING" => "N",
"PAGER_DESC_NUMBERING_CACHE_TIME" => "36000",
"PAGER_SHOW_ALL" => "Y",
"HIDE_NOT_AVAILABLE" => "N",
"CONVERT_CURRENCY" => "N",
"OFFERS_CART_PROPERTIES" => array("COLOR"),
"AJAX_OPTION_JUMP" => "N",
"AJAX_OPTION_STYLE" => "Y",
"AJAX_OPTION_HISTORY" => "N"
),
false
);?>
</div>
<div class="right">
<span class="product__avilability green"><?if($arResult['CAN_BY']=="Y"){?>Есть в наличии<?}?></span>
<div class="product__price">
<?if (!isset($arResult['OFFERS']) || empty($arResult['OFFERS']))
{
$price = explode(".", $arResult['MIN_PRICE']['PRINT_DISCOUNT_VALUE']);
}else{
$price = explode(".", $arResult['OFFERS'][0]['MIN_PRICE']['PRINT_DISCOUNT_VALUE']);
}?>
<span class="actual-price"><strong><?=$price[0]?></strong> Руб.</span>
<?
if (!isset($arResult['OFFERS']) || empty($arResult['OFFERS']))
{
$boolDiscountShow = (0 < $arResult['OFFERS'][0]['MIN_PRICE']['DISCOUNT_DIFF']);
?><span class="old-price" st yle="display: <? echo ($boolDiscountShow ? '' : 'none'); ?>"><? echo ($boolDiscountShow ? $arResult['OFFERS'][0]['MIN_PRICE']['PRINT_VALUE'] : ''); ?> Руб.</span><?
}else{
$boolDiscountShow = (0 < $arResult['MIN_PRICE']['DISCOUNT_DIFF']);
?><span class="old-price" st yle="display: <? echo ($boolDiscountShow ? '' : 'none'); ?>"><? echo ($boolDiscountShow ? $arResult['MIN_PRICE']['PRINT_VALUE'] : ''); ?> Руб.</span><?
}
?>
</div>
<div class="product__colors">
<ul></ul>
</div>
<div class="product__buy">
<a href="#" class="product__buy-submit"><span>Купить</span></a>
<div class="quantityInput">
<a class="minus"><div></div></a>
<input type="text" name="quantity" maxlength="2" value="1" />
<a class="plus"><div></div></a>
</div>
</div>
<div class="product__delivery">
<?$APPLICATION->IncludeComponent(
"bitrix:main.include",
"",
Array(
"AREA_FILE_SHOW" => "file",
"PATH" => "/include/product_del.php",
"EDIT_TEMPLATE" => ""
),
false
);?>
<?$APPLICATION->IncludeComponent(
"bitrix:main.include",
"",
Array(
"AREA_FILE_SHOW" => "file",
"PATH" => "/include/product_del2.php",
"EDIT_TEMPLATE" => ""
),
false
);?>
</div>
<div class="product__shortDescription">
<p><?=$arResult['PREVIEW_TEXT']?></p>
</div>
<div class="product__parameters">
<div class="product__parameters-visible">
<span class="header-large">Характеристики</span>
<?
$cvb = 0;
foreach($arGroupdProp as $nameGroup => $arPrpGroup){?>
<span class="header"><?=$nameGroup?></span>
<table>
<?foreach($arPrpGroup as $props){?>
<tr>
<td><?=$props["NAME"]?></td>
<td><?=$props["VALUE"]?></td>
</tr>
<?
$c++;
if($c==6){break;}
}?>
</table>
<?
if($c==6){break;}
}?>
</div>
<a class="product__parameters-link">Все характеристики</a>
<div class="product__parameters-hidden">
<?foreach($arGroupdProp as $nameGroup => $arPrpGroup){?>
<span class="header"><?=$nameGroup?></span>
<table>
<?foreach($arPrpGroup as $props){?>
<tr>
<td><?=$props["NAME"]?></td>
<td><?=$props["VALUE"]?></td>
</tr>
<?}?>
</table>
<?}?>
</div>
</div>
</div>
</div>
<div id="basket-add-popup" class="popup">
<span class="text">Товар добавлен в корзину</span>
<div class="block-bottom">
<a class="back-link"><span>Продолжить покупки</span></a>
<a class="order-button" href="/cart/"><span>Оформить заказ</span></a>
</div>
</div>
</section>
|
|