Модификации товаров
А, понял, тип "Список" в халяве не доступен, т.е. автоматически создать модификации не получится...
как же тогда реализовать выбор нужного цвета и размера прямо в карточке товара 

модификации можно загрузить и через csv файл, а доп свойства размер и цвет сделать текстовыми
Разобрался, спасибо!
А еще вопрос. Я создал несколько модификаций с разными свойствами, теперь свойства выводятся в самом товаре радиокнопками, а снизу еще выводится список модификаций, каждая из которых - по сути тот же товар. В корзину можно добавить как сам товар, так и его модификации, что совсем несуразно. Как сделать так, чтобы при добавлении в корзину основного товара с выбранными цветом и размером, в корзину добавлялась именно его соответствующая модификация?
А еще вопрос. Я создал несколько модификаций с разными свойствами, теперь свойства выводятся в самом товаре радиокнопками, а снизу еще выводится список модификаций, каждая из которых - по сути тот же товар. В корзину можно добавить как сам товар, так и его модификации, что совсем несуразно. Как сделать так, чтобы при добавлении в корзину основного товара с выбранными цветом и размером, в корзину добавлялась именно его соответствующая модификация?
Как в товаре вывести каталог модификаций. У меня каталог организаций, это как вариант реализовать инфраструктуры. И за слабого знания XSL помогите буду благодарен.
Skype:ferdinant1988 ICQ:311960596 E-mail: ferdinant@i.ua
ferdinant писал(а):
в начале темы есть куски кода
к в товаре вывести каталог модификаций. У меня каталог организаций, это как вариант реализовать инфраструктуры. И за слабого знания XSL помогите буду благодарен.
в начале темы есть куски кода
Qualis писал(а):
HostCMS писал(а):
DStorm писал(а):
Вот только не понимаю в <input name="property133" size="20" value="" type="radio">S<br> - Так и должно быть? я про значение value?
МагазинТовар:Цитата:
<?xml version="1.0" encoding="windows-1251"?>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output xmlns="http://www.w3.org/TR/xhtml1/strict" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="Windows-1251" indent="yes" method="html" omit-xml-declaration="no" version="1.0" media-type="text/xml"/>
<xsl
ecimal-format name="my" decimal-separator="," grouping-separator=" "/>
<xsl:key name="property133" match="/shop/item/modifications/item/property[@xml_name='razm_odez']" use="value"/>
<xsl:key name="property135" match="/shop/item/modifications/item/property[@xml_name='rost']" use="value"/>
<xsl:template match="/shop">
<xsl:apply-templates select="item"/>
</xsl:template>
<xsl:template match="item">
<SCRIPT>
<xsl:comment>
<xsl:text disable-output-escaping="yes">
<![CDATA[
function GetRadioValueModif(radioName)
{
var value = false;
var radioObject = document.getElementsByName(radioName);
if (radioObject!= undefined)
{
for (var i = 0; i < radioObject.length; i++)
{
if (radioObject[i].checked)
{
value = radioObject[i].value;
break;
}
}
}
return value;
}
function ShowImgWindow(title, src, width, height)
{
obj = window.open("", "", "scrollbars=0,dialog=0,minimizable=1,modal=1,width="+width+",height="+height+",resizable=0"
;
obj.document.write("<html>"
;
obj.document.write("<head>"
;
obj.document.write("<title>"+title+"</title>"
;
obj.document.write("</head>"
;
obj.document.write("<body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>"
;
obj.document.write("<img src=\""+src+"\" />"
;
obj.document.write("</body>"
;
obj.document.write("</html>"
;
}
// массив для хранения текущих рейтингов звезд
var curr_rate = new Array();
// функция работы со звездами рейтинга
function set_rate(id, new_rate)
{
// устанавливаем атрибуты
curr_star = document.getElementById(id);
parent_id = parseInt(curr_star.parentNode.id);
// при первом пересчете ставим рейтинг для группы звезд в 0
if (!curr_rate[parent_id])
{
curr_rate[parent_id] = 0;
}
// устанавливаем новый рейтинг в массив рейтингов и значение скрытого поля
if (new_rate != curr_rate[parent_id] && parseInt(new_rate) > 0)
{
curr_rate[parent_id] = new_rate;
curr_form = document.getElementById('comment_form_0' + (parent_id != 0 ? parent_id : ''
);
curr_form.shop_comment_grade.value = curr_rate[parent_id].charAt(curr_rate[parent_id].length - 1);
}
// пересчет стилей для звезд
for (i = 1; i < 6; i++)
{
if (parent_id != 0)
{
j = parent_id + '' + i + '_star_' + i;
}
else
{
j = i + '_star_' + i;
}
temp_obj = document.getElementById(j);
if (new_rate == 0)
{
id = curr_rate[parent_id];
}
if (parseInt(j) > parseInt(id))
{
temp_obj.className = '';
}
else
{
temp_obj.className = 'curr';
}
}
}
]]>
</xsl:text>
</xsl:comment>
</SCRIPT>
<div>
<h1>
<xsl:value-of disable-output-escaping="yes" select="name"/>
</h1>
</div>
<!-- Получаем ID родительской группы и записываем в переменную $parent_group_id -->
<xsl:variable name="parent_group_id" select="/shop/@current_group_id"/>
<xsl:if test="$parent_group_id = 0">
<a href="{/shop/path}">
<xsl:value-of disable-output-escaping="yes" select="/shop/name"/>
</a>
</xsl:if>
<!-- Путь к группе -->
<xsl:apply-templates select="//group[@id=$parent_group_id]" mode="goup_path"/>
<span class="path_arrow">→</span>
<b>
<a href="{/path}">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a>
</b>
<div style="float: left; margin: 20px 0px 0px 20px">
<!-- Средняя оценка товара -->
<xsl:if test="comments/average_grade/node()">
<xsl:call-template name="show_average_grade">
<xsl:with-param name="grade" select="comments/average_grade"/>
<xsl:with-param name="const_grade" select="5"/>
</xsl:call-template>
</xsl:if>
</div>
<div style="clear: both"></div>
<!-- Информация об ошибках -->
<xsl:variable name="error_code" select="/shop/error"/>
<xsl:if test="$error_code != 0">
<div id="error">
<b>Внимание!</b>Неправильно введен код подтвержения!</div>
</xsl:if>
<xsl:if test="not(/shop/error/node()) and /shop/comment_is_active/node()">
<!-- Информация о выполненном действии -->
<div style="border: 1px solid #dadada; padding: 10px; width: 400px">
<b>
<xsl:choose>
<xsl:when test="/shop/comment_is_active = '0'">Комментарий успешно добавлен и будет опубликован после проверки модератором!</xsl:when>
<xsl:otherwise>Комментарий успешно добавлен и опубликован!</xsl:otherwise>
</xsl:choose>
</b>
</div>
</xsl:if>
<div>
<!-- Изображение для товара, если есть -->
<xsl:if test="small_image != ''">
<div style="float: left; width: {small_image/@width}px; margin: 0px 10px 10px 0px; color: #aaaaaa;">
<a href="{image}" target="blank_" onclick="ShowImgWindow('{name}','{image}', {image/@width}, {image/@height}); return false;">
<img src="{small_image}" style="border: 1px solid #DADADA; margin: 0px 5px 5px 0px"/>
</a>
<br/>
<a href="{image}" target="blank_" onclick="ShowImgWindow('{name}','{image}', {image/@width}, {image/@height}); return false;">
<img src="/hostcmsfiles/images/zoom.gif" alt="Увеличить" />
</a>
</div>
</xsl:if>
<!-- Цена товара -->
<p>Цена:
<span style="font-size: 11pt; font-weight: bold">
<xsl:choose>
<xsl:when test="price != 0">
<xsl:value-of select="format-number(price, '### ###,00', 'my'
"/> <xsl:value-of select="currency" disable-output-escaping="yes"/>
</xsl:when>
<xsl:otherwise>договорная</xsl:otherwise>
</xsl:choose>
</span>
<br/>
<!-- Если цена со скидкой - выводим ее -->
<xsl:if test="price!=price_tax">
<span style="color: gray; text-decoration: line-through;">
<xsl:variable name="pric_tax" select="price_tax"/>
<span style="font-size: 11pt">
<xsl:value-of select="format-number($pric_tax, '### ###,00', 'my'
"/> <xsl:value-of disable-output-escaping="yes" select="currency"/></span>
</span>
<br/>
</xsl:if>
</p>
<div>
<xsl:choose>
<xsl:when test="modifications/item/property[@xml_name='razm_odez']/node() or modifications/item/property[@xml_name='rost']/node()">
<!-- Ссылку на добавление в корзины выводим, если:
type = 0 - простой тип товара
type = 1 - электронный товар, при этом остаток на складе больше 0 или -1,
что означает неограниченное количество -->
<xsl:if test="type = 0 or (type = 1 and (eitem_count > 0 or eitem_count = -1))">
<p>
<input type="text" size="3" value="1" id="count_{@id}"/>
<a href="{/shop/path}cart/?action=add&item_id={@id}" onclick="return AddIntoCart('{/shop/path}', {@id}, document.getElementById('count_{@id}'
.value + '&property133=' + GetRadioValueModif('property133'
+ '&property135=' + GetRadioValueModif('property135'
)" style="text-decoration: none;"><img alt="В корзину" title="В корзину" src="/hostcmsfiles/images/cart.gif" style="margin: 0px 0px -4px 10px" />В корзину
</a>
</p>
</xsl:if>
<!-- Размер одежды-->
<xsl:if test="modifications/item/property[@xml_name='razm_odez']/node()">
<div style="width: 60px; float: left; padding:0 15px;">
<h4>Размеры</h4>
<xsl:apply-templates select="modifications/item/property[@xml_name='razm_odez' and generate-id(.)=generate-id(key('property133', value))]"/>
</div>
</xsl:if>
<!-- Рост -->
<xsl:if test="modifications/item/property[@xml_name='rost']/node()">
<div style="width: 60px; float: left; padding:0 15px;">
<h4>Рост</h4>
<xsl:apply-templates select="modifications/item/property[@xml_name='rost' and generate-id(.)=generate-id(key('property135', value))]"/>
</div>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<p>
<input type="text" size="3" value="1" id="count_{@id}"/>
<a href="{/shop/path}cart/?action=add&item_id={@id}" onclick="return AddIntoCart('{/shop/path}', {@id}, document.getElementById('count_{@id}'
.value)" style="text-decoration: none;">
<img alt="В корзину" title="В корзину" src="/hostcmsfiles/images/cart.gif" style="margin: 0px 0px -4px 10px" />В корзину
</a>
</p>
</xsl:otherwise>
</xsl:choose>
</div>
<xsl:if test="marking_of_goods != ''">
<p>Артикул: <b><xsl:value-of disable-output-escaping="yes" select="marking_of_goods"/></b></p>
</xsl:if>
<xsl:if test="producer/name != ''">
<p>Производитель: <b><xsl:value-of disable-output-escaping="yes" select="producer/name"/></b></p>
</xsl:if>
<!-- Если указан вес товара -->
<xsl:if test="weight != 0">
<p>Вес товара: <xsl:value-of select="weight"/> <xsl:value-of select="weight_mesure"/></p>
</xsl:if>
<!-- Показываем скидки -->
<xsl:if test="count(discount) > 0">
<xsl:apply-templates select="discount"/>
</xsl:if>
<!-- Показываем количество на складе, если больше нуля -->
<xsl:if test="rest > 0">
<p>В наличии: <xsl:value-of disable-output-escaping="yes" select="rest"/> <xsl:value-of disable-output-escaping="yes" select="mesure"/></p>
</xsl:if>
<!-- Описание товара -->
<xsl:value-of disable-output-escaping="yes" select="description" />
<!-- Если электронный товар, выведим доступное количество -->
<xsl:if test="type = 1">
<p>
<strong>
<xsl:choose>
<xsl:when test="eitem_count = 0">
Электронный товар закончился.
</xsl:when>
<xsl:when test="eitem_count = -1">
Электронный товар доступен для заказа.
</xsl:when>
<xsl:otherwise>
На складе осталось: <xsl:value-of select="eitem_count" /><xsl:text> </xsl:text><xsl:value-of select="mesure" />
</xsl:otherwise>
</xsl:choose>
</strong>
</p>
</xsl:if>
<!-- Текст товара -->
<p>
<xsl:value-of disable-output-escaping="yes" select="text"/>
</p>
<div style="clear: both;"></div>
<xsl:if test="count(property) > 0">
<h2>Атрибуты товара</h2>
<!-- Свойства в корневой группе -->
<xsl:if test="count(property[@dir_id = 0])">
<table border="0">
<xsl:apply-templates select="property[@dir_id = 0]"/>
</table>
</xsl:if>
<!-- Выбираем список групп свойств -->
<xsl:apply-templates select="/shop/properties_items_dir"/>
</xsl:if>
</div>
<!-- Тэги для информационного элемента -->
<xsl:if test="count(tags/tag) > 0">
<p>
<img src="/hostcmsfiles/images/tags.gif" align="left" style="margin: 0px 5px -2px 0px"/>
<xsl:apply-templates select="tags/tag"/>
</p>
</xsl:if>
<!-- Модификации -->
<xsl:if test="count(modifications/item[not(property[@id=133]/node()) and not(property[@id=135]/node())]) > 0">
<div>
<h2>Модификации:</h2>
<table cellspacing="3" cellpadding="3" style="margin-left: -6px;">
<tr>
<td style="border-bottom: 1px solid #dadada;">Название</td>
<td style="border-bottom: 1px solid #dadada;">Цена</td>
</tr>
<xsl:apply-templates select="modifications/item[not(property[@id=133]/node()) and not(property[@id=135]/node())]"/>
</table>
</div>
</xsl:if>
<xsl:if test="count(tying/item) > 0">
<p>
<b>Сопутствующие товары:</b>
</p>
<!-- Отображаем сопутствующие товары -->
<xsl:apply-templates select="tying/item"/>
<div style="clear: both;"></div>
</xsl:if>
<!-- Отзывы о товаре -->
<xsl:if test="count(comments/comment) > 0">
<p class="title">
<a name="comments"></a>Отзывы о товаре</p>
<xsl:apply-templates select="comments/comment" />
</xsl:if>
<div id="ShowAddComment">
<a href="javascript:void(0)" onclick="javascript:cr('AddComment'
">Добавить комментарий</a>
</div>
<div id="AddComment" style="display: none">
<xsl:call-template name="AddCommentForm"></xsl:call-template>
</div>
</xsl:template>
<!-- Шаблон вывода добавления комментария -->
<xsl:template name="AddCommentForm">
<xsl:param name="comment_id" select="0"/>
<!-- Заполняем форму -->
<xsl:variable name="subject">
<xsl:if test="/document/form_parent_id/node() and /document/form_parent_id/node() and /document/form_parent_id= $comment_id">
<xsl:value-of select="/document/form_subject"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="email">
<xsl:if test="/document/form_user_email/node() and /document/form_parent_id/node() and /document/form_parent_id= $comment_id">
<xsl:value-of select="/document/form_user_email"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="text">
<xsl:if test="/document/form_text/node() and /document/form_parent_id/node() and /document/form_parent_id= $comment_id">
<xsl:value-of disable-output-escaping="yes" select="/document/form_text"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="name">
<xsl:if test="/document/form_user_name/node() and /document/form_parent_id/node() and /document/form_parent_id= $comment_id">
<xsl:value-of select="/document/form_user_name"/>
</xsl:if>
</xsl:variable>
<div class="comment">
<div class="tl"></div>
<div class="tr"></div>
<div class="bl"></div>
<div class="br"></div>
<!--Отображение формы добавления комментария-->
<form action="{/document/url}" name="comment_form_0{comment_id}" method="post">
<!-- Авторизированным не показываем -->
<xsl:if test="/shop/user_id = 0">
Имя
<br/>
<input type="text" size="70" name="shop_comment_user_name" value="{/shop/shop_comment_user_name}"/>
<p>
E-mail
<br/>
<input id="email{$comment_id}" type="text" size="70" name="shop_comment_user_email" value="{/shop/shop_comment_user_email}"
onblur="FieldCheckEmail(this.id)"
onkeyup="FieldCheckEmail(this.id)"
onkeydown="FieldCheckEmail(this.id)" />
<div id="error_email{$comment_id}"></div>
</p>
</xsl:if>
<p>
Тема
<br/>
<input type="text" size="70" name="shop_comment_subject" value="{/shop/shop_comment_subject}"/>
</p>
<p>
Комментарий
<br/>
<textarea name="shop_comment_text" cols="68" rows="5" class="mceEditor"><xsl:value-of select="/shop/shop_comment_text"/></textarea>
</p>
<p>
Оценка
<br/>
<input type="hidden" name="shop_comment_grade" value="0"/>
<xsl:variable name="ul_id">
<xsl:choose>
<xsl:when test="comment_id > 0"><xsl:value-of select="comment_id"/>_stars</xsl:when>
<xsl:otherwise>0_stars</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<ul id="{$ul_id}" class="stars">
<li onclick="set_rate(this.id, this.id)" onmouseover="set_rate(this.id, '-1'
" onmouseout="set_rate(this.id, 0)" id="{comment_id}1_star_1"></li>
<li onclick="set_rate(this.id, this.id)" onmouseover="set_rate(this.id, '-1'
" onmouseout="set_rate(this.id, 0)" id="{comment_id}2_star_2"></li>
<li onclick="set_rate(this.id, this.id)" onmouseover="set_rate(this.id, '-1'
" onmouseout="set_rate(this.id, 0)" id="{comment_id}3_star_3"></li>
<li onclick="set_rate(this.id, this.id)" onmouseover="set_rate(this.id, '-1'
" onmouseout="set_rate(this.id, 0)" id="{comment_id}4_star_4"></li>
<li onclick="set_rate(this.id, this.id)" onmouseover="set_rate(this.id, '-1'
" onmouseout="set_rate(this.id, 0)" id="{comment_id}5_star_5"></li>
</ul>
</p>
<br/>
<!-- Обработка CAPTCHA -->
<xsl:if test="//captcha_key != 0 and /shop/user_id = 0">
Контрольные цифры
<sup>
<font color="red">*</font>
</sup>
<div style="float: left">
<img id="comment_{$comment_id}" style="border: 1px solid #000000" src="/captcha.php?get_captcha={captcha_key}{$comment_id}&height=30&width=100" title="Код подтверждения" name="captcha"/>
</div>
<div id="captcha" style="clear:both;">
<img style="border: 0px" src="/hostcmsfiles/images/refresh.gif" /> <a href="javascript:void(0);" onclick="ReNewCaptchaById('comment_{$comment_id}', '{//captcha_key}{$comment_id}', 30); return false;">Показать другое число</a>
</div>
<div style="float: left;margin-top: 5px">
<input type="hidden" name="captcha_key" value="{//captcha_key}{$comment_id}"/>
<input type="text" name="captcha_keystring" size="15"/>
</div>
<div id="captcha" style="clear:both;margin-bottom:10px;">
Введите число, которое указано выше.
</div>
</xsl:if>
<xsl:if test="$comment_id != 0">
<input type="hidden" name="comment_parent_id" value="{comment_id}"/>
</xsl:if>
<p>
<input id="submit_email{$comment_id}" type="submit" name="submit_comment" value="Опубликовать"/>
</p>
</form>
</div>
</xsl:template>
<!-- Вывод раздела для свойств товара -->
<xsl:template match="properties_items_dir">
<xsl:variable name="dir_id" select="@id"/>
<xsl:if test="count(/shop/item/property[@dir_id = $dir_id])">
<!-- Название группы свойств -->
<p><b><xsl:value-of select="shop_properties_items_dir_name"/></b></p>
<table border="0">
<xsl:apply-templates select="/shop/item/property[@dir_id = $dir_id]"/>
</table>
</xsl:if>
<xsl:if test="count(properties_items_dir) > 0">
<blockquote>
<xsl:apply-templates select="properties_items_dir"/>
</blockquote>
</xsl:if>
</xsl:template>
<!-- Вывод строки со значением свойства -->
<xsl:template match="property">
<xsl:if test="value != '' or (type = 1 and file_path != ''
">
<tr>
<td style="padding: 5px" bgcolor="#E5DFDA">
<b><xsl:value-of select="name"/></b>
</td>
<td style="padding: 5px" bgcolor="#E5DFDA">
<xsl:choose>
<xsl:when test="type = 1">
<a href="{file_path}">Скачать файл</a>
</xsl:when>
<xsl:when test="type = 7">
<xsl:choose>
<xsl:when test="value = 1">
<input type="checkbox" checked="" disabled="" />
</xsl:when>
<xsl:otherwise>
<input type="checkbox" disabled="" />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of disable-output-escaping="yes" select="value"/>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:if>
</xsl:template>
<!-- /// Метки для информационного элемента /// -->
<xsl:template match="tags/tag">
<a href="{/shop/path}tag/{tag_path_name}/" class="tag">
<xsl:value-of select="tag_name"/>
</a>
<xsl:if test="position() != last()">,</xsl:if> 
</xsl:template>
<!-- Шаблон для модификаций -->
<xsl:template match="modifications/item">
<tr>
<td>
<!-- Название модификации -->
<a href="{/shop/path}{fullpath}{path}/">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a>
</td>
<td>
<!-- Цена модификации -->
<xsl:value-of disable-output-escaping="yes" select="price"/> 
<!-- Валюта -->
<xsl:value-of disable-output-escaping="yes" select="currency"/>
</td>
</tr>
</xsl:template>
<!-- Вывод рейтинга товара -->
<xsl:template name="show_average_grade">
<xsl:param name="grade" select="0"/>
<xsl:param name="const_grade" select="0"/>
<!-- Чтобы избежать зацикливания -->
<xsl:variable name="current_grade" select="$grade * 1"/>
<xsl:choose>
<!-- Если число целое -->
<xsl:when test="floor($current_grade) = $current_grade and not($const_grade > ceiling($current_grade))">
<xsl:if test="$current_grade - 1 > 0">
<xsl:call-template name="show_average_grade">
<xsl:with-param name="grade" select="$current_grade - 1"/>
<xsl:with-param name="const_grade" select="$const_grade - 1"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$current_grade != 0">
<img src="/hostcmsfiles/images/stars_single.gif"/>
</xsl:if>
</xsl:when>
<xsl:when test="$current_grade != 0 and not($const_grade > ceiling($current_grade))">
<xsl:if test="$current_grade - 0.5 > 0">
<xsl:call-template name="show_average_grade">
<xsl:with-param name="grade" select="$current_grade - 0.5"/>
<xsl:with-param name="const_grade" select="$const_grade - 1"/>
</xsl:call-template>
</xsl:if>
<img src="/hostcmsfiles/images/stars_half.gif"/>
</xsl:when>
<xsl:otherwise>
<!-- Выводим серые звездочки, пока текущая позиция не дойдет то значения, увеличенного до целого -->
<xsl:call-template name="show_average_grade">
<xsl:with-param name="grade" select="$current_grade"/>
<xsl:with-param name="const_grade" select="$const_grade - 1"/>
</xsl:call-template>
<img src="/hostcmsfiles/images/stars_gray.gif"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Шаблон для вывода звездочек (оценки) -->
<xsl:template name="for">
<xsl:param name="i" select="0"/>
<xsl:param name="n"/>
<input type="radio" name="shop_comment_grade" value="{$i}" id="id_shop_comment_grade_{$i}">
<xsl:if test="/shop/shop_comment_grade = $i">
<xsl:attribute name="checked">
</xsl:attribute>
</xsl:if>
</input> 
<label for="id_shop_comment_grade_{$i}">
<xsl:call-template name="show_average_grade">
<xsl:with-param name="grade" select="$i"/>
<xsl:with-param name="const_grade" select="5"/>
</xsl:call-template>
</label>
<br/>
<xsl:if test="$n > $i and $n > 1">
<xsl:call-template name="for">
<xsl:with-param name="i" select="$i + 1"/>
<xsl:with-param name="n" select="$n"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- Шаблон для отзывов -->
<xsl:template match="comments/comment">
<a name="comment{@id}"></a>
<div class="comment">
<div class="tl"></div>
<div class="tr"></div>
<div class="bl"></div>
<div class="br"></div>
<xsl:if test="subject != ''">
<div>
<strong>
<xsl:value-of select="subject"/>
</strong>
</div>
</xsl:if>
<xsl:value-of select="text" disable-output-escaping="yes"/>
<!-- Оценка комментария -->
<xsl:if test="grade != 0">
<div>Оценка:
<xsl:call-template name="show_average_grade">
<xsl:with-param name="grade" select="grade"/>
<xsl:with-param name="const_grade" select="5"/>
</xsl:call-template>
</div>
</xsl:if>
</div>
<div class="comment_desc">
<xsl:choose>
<xsl:when test="user_name">
<xsl:value-of select="user_name"/>
</xsl:when>
<xsl:otherwise>
<img src="/hostcmsfiles/images/user.gif" style="margin: 0px 5px -4px 0px" />
<b>
<a href="/users/info/{site_user_login}/" class="c_u_l" ><xsl:value-of select="site_user_login"/></a>
</b>
</xsl:otherwise>
</xsl:choose> · <xsl:value-of select="date_time"/> · <a href="{/shop/path}{/shop/item/fullpath}{/shop/item/path}/#comment{@id}" title="ссылка">#</a>
</div>
</xsl:template>
<!-- Шаблон для скидки -->
<xsl:template match="discount">
<p>
<xsl:value-of disable-output-escaping="yes" select="name"/> <xsl:value-of disable-output-escaping="yes" select="value"/>%
</p>
</xsl:template>
<xsl:template match="tying/item">
<div style="clear: both">
<p>
<a href="{/shop/path}{fullpath}{path}/">
<xsl:value-of select="name"/>
</a>
</p>
<!-- Изображение для товара, если есть -->
<xsl:if test="small_image != ''">
<a href="{/shop/path}{fullpath}{path}/">
<img src="{small_image}" align="left" style="border: 1px solid #000000; margin: 0px 5px 5px 0px"/>
</a>
</xsl:if>
<p>
<xsl:value-of disable-output-escaping="yes" select="description"/>
</p>
<!-- Цена товара -->
<strong>
<xsl:choose>
<xsl:when test="price != 0">
<xsl:value-of disable-output-escaping="yes" select="price"/> 
<!-- Валюта товара -->
<xsl:value-of disable-output-escaping="yes" select="currency"/>
</xsl:when>
<xsl:otherwise>договорная</xsl:otherwise>
</xsl:choose>
</strong>
<!-- Если цена со скидкой - выводим ее -->
<xsl:if test="price!=price_tax">
<br/>
<font color="gray">
<strike>
<xsl:value-of disable-output-escaping="yes" select="price_tax"/> <xsl:value-of disable-output-escaping="yes" select="currency"/></strike>
</font>
</xsl:if>
<!-- Если указан вес товара -->
<xsl:if test="weight != 0">
<br/>Вес товара: <xsl:value-of select="weight"/> <xsl:value-of select="weight_mesure"/></xsl:if>
<!-- Показываем скидки -->
<xsl:if test="count(discount) > 0">
<xsl:apply-templates select="discount"/>
</xsl:if>
<!-- Показываем количество на складе, если больше нуля -->
<xsl:if test="rest > 0">
<br/>В наличии: <xsl:value-of disable-output-escaping="yes" select="rest"/></xsl:if>
<xsl:if test="producer/name != ''">
<br/>Производитель: <xsl:value-of disable-output-escaping="yes" select="producer/name"/></xsl:if>
</div>
</xsl:template>
<!-- Шаблон выводит хлебные крошки -->
<xsl:template match="group" mode="goup_path">
<xsl:variable name="parent_id" select="@parent"/>
<!-- Выбираем рекурсивно вышестоящую группу -->
<xsl:apply-templates select="//group[@id=$parent_id]" mode="goup_path"/>
<xsl:if test="@parent=0">
<a href="{/shop/path}">
<xsl:value-of select="/shop/name"/>
</a>
</xsl:if>
<span class="path_arrow">→</span>
<a href="{/shop/path}{fullpath}">
<xsl:value-of select="name"/>
</a>
</xsl:template>
<!-- для размеров -->
<xsl:template match="modifications/item/property[@xml_name='razm_odez']">
<xsl:variable name="value" select="value" />
<xsl:choose>
<xsl:when test="position() = 1">
<input name="property133" size="20" type="radio" value="{/shop/properties_for_group/property[@xml_name='razm_odez']/list_items/list_item[list_item_value=$value]/@id}" checked=""/><xsl:value-of select="value"/><br />
</xsl:when>
<xsl:otherwise>
<input name="property133" size="20" type="radio" value="{/shop/properties_for_group/property[@xml_name='razm_odez']/list_items/list_item[list_item_value=$value]/@id}" /><xsl:value-of select="value"/><br />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- для ростов -->
<xsl:template match="modifications/item/property[@xml_name='rost']">
<xsl:variable name="value" select="value" />
<xsl:choose>
<xsl:when test="position() = 1">
<input name="property135" size="20" type="radio" value="{/shop/properties_for_group/property[@xml_name='rost']/list_items/list_item[list_item_value=$value]/@id}" checked="checked"/><xsl:value-of select="value"/><br />
</xsl:when>
<xsl:otherwise>
<input name="property135" size="20" type="radio" value="{/shop/properties_for_group/property[@xml_name='rost']/list_items/list_item[list_item_value=$value]/@id}" /><xsl:value-of select="value"/><br />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Корзина Цитата:
<?php
/* Создаем экземпляр класса магазина (при создании устанавливаем флаг необходимости очитстки кукисов в истину) */
$shop = & singleton('shop'
;
/* Идентификатор интернет-магазина */
$shop_id = to_int($GLOBALS['LA']['shop_id']);
/**
* Использовать ли контроль данных, полученных из cookies
*/
// $shop->use_cookies_read_control = true;
// Обработка AJAX-запросов при заказе
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'get_location' && isset($_REQUEST['shop_country_id']))
{
$shop_country_id = to_int($_REQUEST['shop_country_id']);
$result = array();
if ($shop_country_id)
{
// Расположения заполняем только тогда, когда страна указана
$res = $shop->GetAllLocation($shop_country_id);
if ($res)
{
while ($row = mysql_fetch_assoc($res))
{
$result[$row['shop_location_id']] = $row['shop_location_name'];
}
}
}
$JsHttpRequest = new JsHttpRequest(SITE_CODING);
$GLOBALS['_RESULT'] = array(
'result' => $result);
echo $JsHttpRequest->LOADER;
exit();
}
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'get_city' && isset($_REQUEST['shop_location_id']))
{
$shop_location_id = to_int($_REQUEST['shop_location_id']);
$result = array();
if ($shop_location_id)
{
// Города заполняем только тогда, когда расположение указано
$res = $shop->GetAllCity($shop_location_id);
if ($res)
{
while ($row = mysql_fetch_assoc($res))
{
$result[$row['shop_city_id']] = $row['shop_city_name'];
}
}
}
$JsHttpRequest = new JsHttpRequest(SITE_CODING);
$GLOBALS['_RESULT'] = array(
'result' => $result);
echo $JsHttpRequest->LOADER;
exit();
}
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'get_cityarea' && isset($_REQUEST['shop_city_id']))
{
$shop_city_id = to_int($_REQUEST['shop_city_id']);
$result = array();
// Города заполняем только тогда, когда расположение указано
if ($shop_city_id)
{
$res = $shop->GetAllCityArea($shop_city_id);
if ($res)
{
while ($row = mysql_fetch_assoc($res))
{
$result[$row['shop_city_area_id']] = $row['shop_city_area_name'];
}
}
}
$JsHttpRequest = new JsHttpRequest(SITE_CODING);
$GLOBALS['_RESULT'] = array(
'result' => $result);
echo $JsHttpRequest->LOADER;
exit();
}
// END обработка AJAX-запросов при заказе
if (class_exists("SiteUsers"
)
{
/* Определяем идентификатор текущего пользователя */
$SiteUsers = & singleton('SiteUsers'
;
$site_users_id = $SiteUsers->GetCurrentSiteUser();
}
else
{
$site_users_id = false;
}
// Повторение заказа
if (to_str($_REQUEST['action']) == 'repeat'
{
$shop_order_guid = to_str($_REQUEST['shop_order_guid']);
$order_row = $shop->GetOrderByGuid($shop_order_guid);
// Заказ найден
if ($order_row)
{
$shop_order_id = $order_row['shop_order_id'];
// Если заказ принадлежит этому пользователю
if ($order_row['site_users_id'] == $site_users_id && $site_users_id != 0)
{
$result_order_items = $shop->GetOrderItems($shop_order_id);
$shop_id_from_order = to_int($order_row['shop_shops_id']);
while ($row = mysql_fetch_assoc($result_order_items))
{
// Число товаров передаем, если посетитеь кладет в корзину больше одного товара
if (to_int( $row['shop_order_items_quantity']) > 0)
{
$count = to_int( $row['shop_order_items_quantity']);
}
/* Добавляем товар в корзину */
$shop->AddIntoCart(array('user_id' => $site_users_id,
'shop_id' => $shop_id_from_order,
'item_id' => $row['shop_items_catalog_item_id'],
'count' => $count));
}
}
}
}
// Запускаем сессию, если пользователь не авторизирован и пришли данные для регистрации
if ($site_users_id == 0 && isset($_POST['site_users_login'])
&& isset($_POST['site_users_password'])
&& isset($_POST['site_users_email'])
&& !isset($_SESSION))
{
session_start();
}
$GLOBALS['external_propertys'] = array();
// Если сессия не была запущена - стартуем ее
if (isset($_POST['step_1_1a']) && !isset($_SESSION) && !class_exists("SiteUsers"
)
{
@session_start();
}
/* Необходимо перенести товары из кукисов в сессию и очистить кукисы */
if ((isset($_POST['step_4']) || isset($_POST['step_1_1a'])) && !class_exists("SiteUsers"
)
{
/* Читаем массив из кукисов */
if (!empty($_COOKIE['CART']))
{
$session_cart = array();
$postpone_items = array();
$cart_from_cookies = $shop->GetCookieCart();
$items = to_array($cart_from_cookies[$shop_id]);
foreach ($items as $key => $value)
{
if ($value['shop_cart_flag_postpone'])
{
/* Оставляем товар в корзине кукисов */
$postpone_items[$key] = $value;
}
else
{
/* Добавляем в корзину сессии */
$session_cart[$key] = $value;
}
}
/* Добавляем данные в сессию */
$_SESSION['CART'][$shop_id] = $session_cart;
/* Если массив с отложенными товарами не пуст - сохраняем его в кукисы */
if (count($postpone_items) > 0 && isset($_POST['step_4']))
{
$cart_from_cookies[$shop_id] = $postpone_items;
}
elseif(isset($_POST['step_4']))
{
/* Удалям целиком кукисы карзины для данного магазина */
unset($cart_from_cookies[$shop_id]);
}
/* Сохраняем данные */
$shop->SetCookieCart($cart_from_cookies, time() + 31536000, '/'
;
}
}
/* Переданы данные для авторизации */
if (isset($_POST['step1_1']))
{
/* Проверяем правильность введенных данных */
$site_users_id = $SiteUsers->ValidUser(to_str($_POST['login']), to_str($_POST['password']));
/* Проверяем подтвердил ли пользователь регистрацию */
if ($site_users_id == -1)
{
$GLOBALS['external_propertys']['error'] = -5; /* Вы не активировали свой аккаунт. По указанному адресу отправлено письмо с инструкцией об активации. После активации Вы можете авторизироваться. */
}
elseif ($site_users_id > 0)
{
// Пользователь ввел верные данные, авторизируем его
$SiteUsers->SetCurrentSiteUser($site_users_id);
}
else
{
/* Неверные данные пользователя */
$GLOBALS['external_propertys']['error'] = -6;
}
}
/* AJAX добавление товара в корзину */
if (isset ($_GET['ajax_add_item_id']))
{
$property_array = array ();
$key_property_array = array ();
if (isset ($_GET) && count($_GET))
{
foreach ($_GET as $key => $val)
{
if (preg_match("'^property([\d]*?)$'si", $key, $preg))
{
$property_array[$preg[1]] = $val;
}
}
}
$param = array ();
$param['shop_id'] = $shop_id;
$param['item_id'] = to_int($_GET['ajax_add_item_id']);
$param['user_id'] = $site_users_id;
// Все модификации товара
$all_modifications = $shop->GetAllModificationItems($param['item_id']);
if ($all_modifications)
{
foreach ($all_modifications as $key => $value)
{
$item_propertys_value = array ();
// Получаем значения всех доп.свойств
foreach ($property_array as $id => $v)
{
$list_property_value = $shop->GetValueItemProperty(to_int($value['shop_items_catalog_item_id']), $id);
// Получаем значение элемента списка
$item_propertys_value[$id] = to_int($list_property_value['shop_properties_items_value']);
}
// Если у модификации совпали все переданные свойства, возвращаем идентификатор модификации
$array_diff = array_diff_assoc($property_array, $item_propertys_value);
if (!count($array_diff))
{
$param['item_id'] = $value['shop_items_catalog_item_id'];
break;
}
}
}
// Число товаров передаем, если посетитеь кладет в корзину больше одного товара
if (to_int($_GET['count']) > 0)
{
$param['count'] = to_int($_GET['count']);
}
// Добавляем товар в корзину
$shop->AddIntoCart($param);
// Отображаем корзину
$JsHttpRequest = new JsHttpRequest(SITE_CODING);
ob_start();
$shop->ShowCart($shop_id, $site_users_id, to_str($GLOBALS['LA']['xsl_little_cart']));
$little_cart_html = ob_get_clean();
$GLOBALS['_RESULT'] = array (
'cart' => $little_cart_html
);
echo $JsHttpRequest->LOADER;
exit ();
}
/* добавление товара в корзину */
if (to_str($_GET['action']) == 'add'
{
$param = array();
$param['shop_id'] = $shop_id;
$param['item_id'] = to_int($_GET['item_id']);
$param['user_id'] = $site_users_id;
// Число товаров передаем, если посетитеь кладет в корзину больше одного товара
if (to_int($_GET['count']) > 0)
{
$param['count'] = to_int($_GET['count']);
}
/* Добавляем товар в корзину */
$shop->AddIntoCart($param);
}
/* Удаляение товара из корзины */
if (to_str($_GET['action']) == 'delete_item'
{
$param = array();
$param['shop_id'] = $shop_id;
$param['item_id'] = to_int($_GET['item_id']);
/* Проверяем наличие пользователя */
if ($site_users_id != 0)
{
$param['user_id'] = $site_users_id;
}
$shop->DeleteCart($param);
}
/* Пересчет товара в корзине */
if (isset($_POST['recount']))
{
$param = array();
foreach ($_POST as $key => $value)
{
$param['item_id'] = $key;
/* Получаем идентификатор записи в корзине по идентификатору пользователя и товара */
$cart_id = $shop->GetItemFromCart($shop_id, $site_users_id, $param['item_id']);
$param['cart_id'] = to_int($cart_id['shop_cart_id']);
$param['user_id'] = $site_users_id;
$param['shop_id'] = $shop_id;
$param['count'] = to_int($value);
/* Если установлен флажок - делаем товар отложенным */
$param['postpone'] = !empty($_POST['flag_postpone'.$key]) ? 1 : 0;
/* Если количество = 0 - удаляем из корзины */
if ($param['count'] == 0)
{
$shop->DeleteCart($param);
}
else
{
$shop->UpdateCart($param);
}
}
}
?>Цитата:
Может быть это только у меня, но в корзину добавляется не модификация, выбранная в списке, а тот товар, в котором находимся.
- У меня такая же проблемаHostCMS писал(а):
Поставьте FireFox с FireBug, откройте окно FireBug (кнопка F12) и при нажатии переключении модификаций посмотрите, не возникают ли ошибки. Если возникают — от них нужно избавляться.
- Ошибок нетDStorm писал(а):
Необходимо включить свойства товара по которым выводятся радиокнопки не на группе товара, куда входит товар, а необходимо включить на МАГАЗИНЕ. т.е. заходите в магазин, и сразу включаете свойства на группе. Должно помочь.
- не помогаетВот только не понимаю в <input name="property133" size="20" value="" type="radio">S<br> - Так и должно быть? я про значение value?
МагазинТовар:Цитата:
<?xml version="1.0" encoding="windows-1251"?>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output xmlns="http://www.w3.org/TR/xhtml1/strict" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="Windows-1251" indent="yes" method="html" omit-xml-declaration="no" version="1.0" media-type="text/xml"/>
<xsl
ecimal-format name="my" decimal-separator="," grouping-separator=" "/><xsl:key name="property133" match="/shop/item/modifications/item/property[@xml_name='razm_odez']" use="value"/>
<xsl:key name="property135" match="/shop/item/modifications/item/property[@xml_name='rost']" use="value"/>
<xsl:template match="/shop">
<xsl:apply-templates select="item"/>
</xsl:template>
<xsl:template match="item">
<SCRIPT>
<xsl:comment>
<xsl:text disable-output-escaping="yes">
<![CDATA[
function GetRadioValueModif(radioName)
{
var value = false;
var radioObject = document.getElementsByName(radioName);
if (radioObject!= undefined)
{
for (var i = 0; i < radioObject.length; i++)
{
if (radioObject[i].checked)
{
value = radioObject[i].value;
break;
}
}
}
return value;
}
function ShowImgWindow(title, src, width, height)
{
obj = window.open("", "", "scrollbars=0,dialog=0,minimizable=1,modal=1,width="+width+",height="+height+",resizable=0"
;obj.document.write("<html>"
;obj.document.write("<head>"
;obj.document.write("<title>"+title+"</title>"
;obj.document.write("</head>"
;obj.document.write("<body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>"
;obj.document.write("<img src=\""+src+"\" />"
;obj.document.write("</body>"
;obj.document.write("</html>"
;}
// массив для хранения текущих рейтингов звезд
var curr_rate = new Array();
// функция работы со звездами рейтинга
function set_rate(id, new_rate)
{
// устанавливаем атрибуты
curr_star = document.getElementById(id);
parent_id = parseInt(curr_star.parentNode.id);
// при первом пересчете ставим рейтинг для группы звезд в 0
if (!curr_rate[parent_id])
{
curr_rate[parent_id] = 0;
}
// устанавливаем новый рейтинг в массив рейтингов и значение скрытого поля
if (new_rate != curr_rate[parent_id] && parseInt(new_rate) > 0)
{
curr_rate[parent_id] = new_rate;
curr_form = document.getElementById('comment_form_0' + (parent_id != 0 ? parent_id : ''
);curr_form.shop_comment_grade.value = curr_rate[parent_id].charAt(curr_rate[parent_id].length - 1);
}
// пересчет стилей для звезд
for (i = 1; i < 6; i++)
{
if (parent_id != 0)
{
j = parent_id + '' + i + '_star_' + i;
}
else
{
j = i + '_star_' + i;
}
temp_obj = document.getElementById(j);
if (new_rate == 0)
{
id = curr_rate[parent_id];
}
if (parseInt(j) > parseInt(id))
{
temp_obj.className = '';
}
else
{
temp_obj.className = 'curr';
}
}
}
]]>
</xsl:text>
</xsl:comment>
</SCRIPT>
<div>
<h1>
<xsl:value-of disable-output-escaping="yes" select="name"/>
</h1>
</div>
<!-- Получаем ID родительской группы и записываем в переменную $parent_group_id -->
<xsl:variable name="parent_group_id" select="/shop/@current_group_id"/>
<xsl:if test="$parent_group_id = 0">
<a href="{/shop/path}">
<xsl:value-of disable-output-escaping="yes" select="/shop/name"/>
</a>
</xsl:if>
<!-- Путь к группе -->
<xsl:apply-templates select="//group[@id=$parent_group_id]" mode="goup_path"/>
<span class="path_arrow">→</span>
<b>
<a href="{/path}">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a>
</b>
<div style="float: left; margin: 20px 0px 0px 20px">
<!-- Средняя оценка товара -->
<xsl:if test="comments/average_grade/node()">
<xsl:call-template name="show_average_grade">
<xsl:with-param name="grade" select="comments/average_grade"/>
<xsl:with-param name="const_grade" select="5"/>
</xsl:call-template>
</xsl:if>
</div>
<div style="clear: both"></div>
<!-- Информация об ошибках -->
<xsl:variable name="error_code" select="/shop/error"/>
<xsl:if test="$error_code != 0">
<div id="error">
<b>Внимание!</b>Неправильно введен код подтвержения!</div>
</xsl:if>
<xsl:if test="not(/shop/error/node()) and /shop/comment_is_active/node()">
<!-- Информация о выполненном действии -->
<div style="border: 1px solid #dadada; padding: 10px; width: 400px">
<b>
<xsl:choose>
<xsl:when test="/shop/comment_is_active = '0'">Комментарий успешно добавлен и будет опубликован после проверки модератором!</xsl:when>
<xsl:otherwise>Комментарий успешно добавлен и опубликован!</xsl:otherwise>
</xsl:choose>
</b>
</div>
</xsl:if>
<div>
<!-- Изображение для товара, если есть -->
<xsl:if test="small_image != ''">
<div style="float: left; width: {small_image/@width}px; margin: 0px 10px 10px 0px; color: #aaaaaa;">
<a href="{image}" target="blank_" onclick="ShowImgWindow('{name}','{image}', {image/@width}, {image/@height}); return false;">
<img src="{small_image}" style="border: 1px solid #DADADA; margin: 0px 5px 5px 0px"/>
</a>
<br/>
<a href="{image}" target="blank_" onclick="ShowImgWindow('{name}','{image}', {image/@width}, {image/@height}); return false;">
<img src="/hostcmsfiles/images/zoom.gif" alt="Увеличить" />
</a>
</div>
</xsl:if>
<!-- Цена товара -->
<p>Цена:
<span style="font-size: 11pt; font-weight: bold">
<xsl:choose>
<xsl:when test="price != 0">
<xsl:value-of select="format-number(price, '### ###,00', 'my'
"/> <xsl:value-of select="currency" disable-output-escaping="yes"/></xsl:when>
<xsl:otherwise>договорная</xsl:otherwise>
</xsl:choose>
</span>
<br/>
<!-- Если цена со скидкой - выводим ее -->
<xsl:if test="price!=price_tax">
<span style="color: gray; text-decoration: line-through;">
<xsl:variable name="pric_tax" select="price_tax"/>
<span style="font-size: 11pt">
<xsl:value-of select="format-number($pric_tax, '### ###,00', 'my'
"/> <xsl:value-of disable-output-escaping="yes" select="currency"/></span></span>
<br/>
</xsl:if>
</p>
<div>
<xsl:choose>
<xsl:when test="modifications/item/property[@xml_name='razm_odez']/node() or modifications/item/property[@xml_name='rost']/node()">
<!-- Ссылку на добавление в корзины выводим, если:
type = 0 - простой тип товара
type = 1 - электронный товар, при этом остаток на складе больше 0 или -1,
что означает неограниченное количество -->
<xsl:if test="type = 0 or (type = 1 and (eitem_count > 0 or eitem_count = -1))">
<p>
<input type="text" size="3" value="1" id="count_{@id}"/>
<a href="{/shop/path}cart/?action=add&item_id={@id}" onclick="return AddIntoCart('{/shop/path}', {@id}, document.getElementById('count_{@id}'
.value + '&property133=' + GetRadioValueModif('property133'
+ '&property135=' + GetRadioValueModif('property135'
)" style="text-decoration: none;"><img alt="В корзину" title="В корзину" src="/hostcmsfiles/images/cart.gif" style="margin: 0px 0px -4px 10px" />В корзину</a>
</p>
</xsl:if>
<!-- Размер одежды-->
<xsl:if test="modifications/item/property[@xml_name='razm_odez']/node()">
<div style="width: 60px; float: left; padding:0 15px;">
<h4>Размеры</h4>
<xsl:apply-templates select="modifications/item/property[@xml_name='razm_odez' and generate-id(.)=generate-id(key('property133', value))]"/>
</div>
</xsl:if>
<!-- Рост -->
<xsl:if test="modifications/item/property[@xml_name='rost']/node()">
<div style="width: 60px; float: left; padding:0 15px;">
<h4>Рост</h4>
<xsl:apply-templates select="modifications/item/property[@xml_name='rost' and generate-id(.)=generate-id(key('property135', value))]"/>
</div>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<p>
<input type="text" size="3" value="1" id="count_{@id}"/>
<a href="{/shop/path}cart/?action=add&item_id={@id}" onclick="return AddIntoCart('{/shop/path}', {@id}, document.getElementById('count_{@id}'
.value)" style="text-decoration: none;"><img alt="В корзину" title="В корзину" src="/hostcmsfiles/images/cart.gif" style="margin: 0px 0px -4px 10px" />В корзину
</a>
</p>
</xsl:otherwise>
</xsl:choose>
</div>
<xsl:if test="marking_of_goods != ''">
<p>Артикул: <b><xsl:value-of disable-output-escaping="yes" select="marking_of_goods"/></b></p>
</xsl:if>
<xsl:if test="producer/name != ''">
<p>Производитель: <b><xsl:value-of disable-output-escaping="yes" select="producer/name"/></b></p>
</xsl:if>
<!-- Если указан вес товара -->
<xsl:if test="weight != 0">
<p>Вес товара: <xsl:value-of select="weight"/> <xsl:value-of select="weight_mesure"/></p>
</xsl:if>
<!-- Показываем скидки -->
<xsl:if test="count(discount) > 0">
<xsl:apply-templates select="discount"/>
</xsl:if>
<!-- Показываем количество на складе, если больше нуля -->
<xsl:if test="rest > 0">
<p>В наличии: <xsl:value-of disable-output-escaping="yes" select="rest"/> <xsl:value-of disable-output-escaping="yes" select="mesure"/></p>
</xsl:if>
<!-- Описание товара -->
<xsl:value-of disable-output-escaping="yes" select="description" />
<!-- Если электронный товар, выведим доступное количество -->
<xsl:if test="type = 1">
<p>
<strong>
<xsl:choose>
<xsl:when test="eitem_count = 0">
Электронный товар закончился.
</xsl:when>
<xsl:when test="eitem_count = -1">
Электронный товар доступен для заказа.
</xsl:when>
<xsl:otherwise>
На складе осталось: <xsl:value-of select="eitem_count" /><xsl:text> </xsl:text><xsl:value-of select="mesure" />
</xsl:otherwise>
</xsl:choose>
</strong>
</p>
</xsl:if>
<!-- Текст товара -->
<p>
<xsl:value-of disable-output-escaping="yes" select="text"/>
</p>
<div style="clear: both;"></div>
<xsl:if test="count(property) > 0">
<h2>Атрибуты товара</h2>
<!-- Свойства в корневой группе -->
<xsl:if test="count(property[@dir_id = 0])">
<table border="0">
<xsl:apply-templates select="property[@dir_id = 0]"/>
</table>
</xsl:if>
<!-- Выбираем список групп свойств -->
<xsl:apply-templates select="/shop/properties_items_dir"/>
</xsl:if>
</div>
<!-- Тэги для информационного элемента -->
<xsl:if test="count(tags/tag) > 0">
<p>
<img src="/hostcmsfiles/images/tags.gif" align="left" style="margin: 0px 5px -2px 0px"/>
<xsl:apply-templates select="tags/tag"/>
</p>
</xsl:if>
<!-- Модификации -->
<xsl:if test="count(modifications/item[not(property[@id=133]/node()) and not(property[@id=135]/node())]) > 0">
<div>
<h2>Модификации:</h2>
<table cellspacing="3" cellpadding="3" style="margin-left: -6px;">
<tr>
<td style="border-bottom: 1px solid #dadada;">Название</td>
<td style="border-bottom: 1px solid #dadada;">Цена</td>
</tr>
<xsl:apply-templates select="modifications/item[not(property[@id=133]/node()) and not(property[@id=135]/node())]"/>
</table>
</div>
</xsl:if>
<xsl:if test="count(tying/item) > 0">
<p>
<b>Сопутствующие товары:</b>
</p>
<!-- Отображаем сопутствующие товары -->
<xsl:apply-templates select="tying/item"/>
<div style="clear: both;"></div>
</xsl:if>
<!-- Отзывы о товаре -->
<xsl:if test="count(comments/comment) > 0">
<p class="title">
<a name="comments"></a>Отзывы о товаре</p>
<xsl:apply-templates select="comments/comment" />
</xsl:if>
<div id="ShowAddComment">
<a href="javascript:void(0)" onclick="javascript:cr('AddComment'
">Добавить комментарий</a></div>
<div id="AddComment" style="display: none">
<xsl:call-template name="AddCommentForm"></xsl:call-template>
</div>
</xsl:template>
<!-- Шаблон вывода добавления комментария -->
<xsl:template name="AddCommentForm">
<xsl:param name="comment_id" select="0"/>
<!-- Заполняем форму -->
<xsl:variable name="subject">
<xsl:if test="/document/form_parent_id/node() and /document/form_parent_id/node() and /document/form_parent_id= $comment_id">
<xsl:value-of select="/document/form_subject"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="email">
<xsl:if test="/document/form_user_email/node() and /document/form_parent_id/node() and /document/form_parent_id= $comment_id">
<xsl:value-of select="/document/form_user_email"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="text">
<xsl:if test="/document/form_text/node() and /document/form_parent_id/node() and /document/form_parent_id= $comment_id">
<xsl:value-of disable-output-escaping="yes" select="/document/form_text"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="name">
<xsl:if test="/document/form_user_name/node() and /document/form_parent_id/node() and /document/form_parent_id= $comment_id">
<xsl:value-of select="/document/form_user_name"/>
</xsl:if>
</xsl:variable>
<div class="comment">
<div class="tl"></div>
<div class="tr"></div>
<div class="bl"></div>
<div class="br"></div>
<!--Отображение формы добавления комментария-->
<form action="{/document/url}" name="comment_form_0{comment_id}" method="post">
<!-- Авторизированным не показываем -->
<xsl:if test="/shop/user_id = 0">
Имя
<br/>
<input type="text" size="70" name="shop_comment_user_name" value="{/shop/shop_comment_user_name}"/>
<p>
<br/>
<input id="email{$comment_id}" type="text" size="70" name="shop_comment_user_email" value="{/shop/shop_comment_user_email}"
onblur="FieldCheckEmail(this.id)"
onkeyup="FieldCheckEmail(this.id)"
onkeydown="FieldCheckEmail(this.id)" />
<div id="error_email{$comment_id}"></div>
</p>
</xsl:if>
<p>
Тема
<br/>
<input type="text" size="70" name="shop_comment_subject" value="{/shop/shop_comment_subject}"/>
</p>
<p>
Комментарий
<br/>
<textarea name="shop_comment_text" cols="68" rows="5" class="mceEditor"><xsl:value-of select="/shop/shop_comment_text"/></textarea>
</p>
<p>
Оценка
<br/>
<input type="hidden" name="shop_comment_grade" value="0"/>
<xsl:variable name="ul_id">
<xsl:choose>
<xsl:when test="comment_id > 0"><xsl:value-of select="comment_id"/>_stars</xsl:when>
<xsl:otherwise>0_stars</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<ul id="{$ul_id}" class="stars">
<li onclick="set_rate(this.id, this.id)" onmouseover="set_rate(this.id, '-1'
" onmouseout="set_rate(this.id, 0)" id="{comment_id}1_star_1"></li><li onclick="set_rate(this.id, this.id)" onmouseover="set_rate(this.id, '-1'
" onmouseout="set_rate(this.id, 0)" id="{comment_id}2_star_2"></li><li onclick="set_rate(this.id, this.id)" onmouseover="set_rate(this.id, '-1'
" onmouseout="set_rate(this.id, 0)" id="{comment_id}3_star_3"></li><li onclick="set_rate(this.id, this.id)" onmouseover="set_rate(this.id, '-1'
" onmouseout="set_rate(this.id, 0)" id="{comment_id}4_star_4"></li><li onclick="set_rate(this.id, this.id)" onmouseover="set_rate(this.id, '-1'
" onmouseout="set_rate(this.id, 0)" id="{comment_id}5_star_5"></li></ul>
</p>
<br/>
<!-- Обработка CAPTCHA -->
<xsl:if test="//captcha_key != 0 and /shop/user_id = 0">
Контрольные цифры
<sup>
<font color="red">*</font>
</sup>
<div style="float: left">
<img id="comment_{$comment_id}" style="border: 1px solid #000000" src="/captcha.php?get_captcha={captcha_key}{$comment_id}&height=30&width=100" title="Код подтверждения" name="captcha"/>
</div>
<div id="captcha" style="clear:both;">
<img style="border: 0px" src="/hostcmsfiles/images/refresh.gif" /> <a href="javascript:void(0);" onclick="ReNewCaptchaById('comment_{$comment_id}', '{//captcha_key}{$comment_id}', 30); return false;">Показать другое число</a>
</div>
<div style="float: left;margin-top: 5px">
<input type="hidden" name="captcha_key" value="{//captcha_key}{$comment_id}"/>
<input type="text" name="captcha_keystring" size="15"/>
</div>
<div id="captcha" style="clear:both;margin-bottom:10px;">
Введите число, которое указано выше.
</div>
</xsl:if>
<xsl:if test="$comment_id != 0">
<input type="hidden" name="comment_parent_id" value="{comment_id}"/>
</xsl:if>
<p>
<input id="submit_email{$comment_id}" type="submit" name="submit_comment" value="Опубликовать"/>
</p>
</form>
</div>
</xsl:template>
<!-- Вывод раздела для свойств товара -->
<xsl:template match="properties_items_dir">
<xsl:variable name="dir_id" select="@id"/>
<xsl:if test="count(/shop/item/property[@dir_id = $dir_id])">
<!-- Название группы свойств -->
<p><b><xsl:value-of select="shop_properties_items_dir_name"/></b></p>
<table border="0">
<xsl:apply-templates select="/shop/item/property[@dir_id = $dir_id]"/>
</table>
</xsl:if>
<xsl:if test="count(properties_items_dir) > 0">
<blockquote>
<xsl:apply-templates select="properties_items_dir"/>
</blockquote>
</xsl:if>
</xsl:template>
<!-- Вывод строки со значением свойства -->
<xsl:template match="property">
<xsl:if test="value != '' or (type = 1 and file_path != ''
"><tr>
<td style="padding: 5px" bgcolor="#E5DFDA">
<b><xsl:value-of select="name"/></b>
</td>
<td style="padding: 5px" bgcolor="#E5DFDA">
<xsl:choose>
<xsl:when test="type = 1">
<a href="{file_path}">Скачать файл</a>
</xsl:when>
<xsl:when test="type = 7">
<xsl:choose>
<xsl:when test="value = 1">
<input type="checkbox" checked="" disabled="" />
</xsl:when>
<xsl:otherwise>
<input type="checkbox" disabled="" />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of disable-output-escaping="yes" select="value"/>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:if>
</xsl:template>
<!-- /// Метки для информационного элемента /// -->
<xsl:template match="tags/tag">
<a href="{/shop/path}tag/{tag_path_name}/" class="tag">
<xsl:value-of select="tag_name"/>
</a>
<xsl:if test="position() != last()">,</xsl:if> 
</xsl:template>
<!-- Шаблон для модификаций -->
<xsl:template match="modifications/item">
<tr>
<td>
<!-- Название модификации -->
<a href="{/shop/path}{fullpath}{path}/">
<xsl:value-of disable-output-escaping="yes" select="name"/>
</a>
</td>
<td>
<!-- Цена модификации -->
<xsl:value-of disable-output-escaping="yes" select="price"/> 
<!-- Валюта -->
<xsl:value-of disable-output-escaping="yes" select="currency"/>
</td>
</tr>
</xsl:template>
<!-- Вывод рейтинга товара -->
<xsl:template name="show_average_grade">
<xsl:param name="grade" select="0"/>
<xsl:param name="const_grade" select="0"/>
<!-- Чтобы избежать зацикливания -->
<xsl:variable name="current_grade" select="$grade * 1"/>
<xsl:choose>
<!-- Если число целое -->
<xsl:when test="floor($current_grade) = $current_grade and not($const_grade > ceiling($current_grade))">
<xsl:if test="$current_grade - 1 > 0">
<xsl:call-template name="show_average_grade">
<xsl:with-param name="grade" select="$current_grade - 1"/>
<xsl:with-param name="const_grade" select="$const_grade - 1"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$current_grade != 0">
<img src="/hostcmsfiles/images/stars_single.gif"/>
</xsl:if>
</xsl:when>
<xsl:when test="$current_grade != 0 and not($const_grade > ceiling($current_grade))">
<xsl:if test="$current_grade - 0.5 > 0">
<xsl:call-template name="show_average_grade">
<xsl:with-param name="grade" select="$current_grade - 0.5"/>
<xsl:with-param name="const_grade" select="$const_grade - 1"/>
</xsl:call-template>
</xsl:if>
<img src="/hostcmsfiles/images/stars_half.gif"/>
</xsl:when>
<xsl:otherwise>
<!-- Выводим серые звездочки, пока текущая позиция не дойдет то значения, увеличенного до целого -->
<xsl:call-template name="show_average_grade">
<xsl:with-param name="grade" select="$current_grade"/>
<xsl:with-param name="const_grade" select="$const_grade - 1"/>
</xsl:call-template>
<img src="/hostcmsfiles/images/stars_gray.gif"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Шаблон для вывода звездочек (оценки) -->
<xsl:template name="for">
<xsl:param name="i" select="0"/>
<xsl:param name="n"/>
<input type="radio" name="shop_comment_grade" value="{$i}" id="id_shop_comment_grade_{$i}">
<xsl:if test="/shop/shop_comment_grade = $i">
<xsl:attribute name="checked">
</xsl:attribute>
</xsl:if>
</input> 
<label for="id_shop_comment_grade_{$i}">
<xsl:call-template name="show_average_grade">
<xsl:with-param name="grade" select="$i"/>
<xsl:with-param name="const_grade" select="5"/>
</xsl:call-template>
</label>
<br/>
<xsl:if test="$n > $i and $n > 1">
<xsl:call-template name="for">
<xsl:with-param name="i" select="$i + 1"/>
<xsl:with-param name="n" select="$n"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- Шаблон для отзывов -->
<xsl:template match="comments/comment">
<a name="comment{@id}"></a>
<div class="comment">
<div class="tl"></div>
<div class="tr"></div>
<div class="bl"></div>
<div class="br"></div>
<xsl:if test="subject != ''">
<div>
<strong>
<xsl:value-of select="subject"/>
</strong>
</div>
</xsl:if>
<xsl:value-of select="text" disable-output-escaping="yes"/>
<!-- Оценка комментария -->
<xsl:if test="grade != 0">
<div>Оценка:
<xsl:call-template name="show_average_grade">
<xsl:with-param name="grade" select="grade"/>
<xsl:with-param name="const_grade" select="5"/>
</xsl:call-template>
</div>
</xsl:if>
</div>
<div class="comment_desc">
<xsl:choose>
<xsl:when test="user_name">
<xsl:value-of select="user_name"/>
</xsl:when>
<xsl:otherwise>
<img src="/hostcmsfiles/images/user.gif" style="margin: 0px 5px -4px 0px" />
<b>
<a href="/users/info/{site_user_login}/" class="c_u_l" ><xsl:value-of select="site_user_login"/></a>
</b>
</xsl:otherwise>
</xsl:choose> · <xsl:value-of select="date_time"/> · <a href="{/shop/path}{/shop/item/fullpath}{/shop/item/path}/#comment{@id}" title="ссылка">#</a>
</div>
</xsl:template>
<!-- Шаблон для скидки -->
<xsl:template match="discount">
<p>
<xsl:value-of disable-output-escaping="yes" select="name"/> <xsl:value-of disable-output-escaping="yes" select="value"/>%
</p>
</xsl:template>
<xsl:template match="tying/item">
<div style="clear: both">
<p>
<a href="{/shop/path}{fullpath}{path}/">
<xsl:value-of select="name"/>
</a>
</p>
<!-- Изображение для товара, если есть -->
<xsl:if test="small_image != ''">
<a href="{/shop/path}{fullpath}{path}/">
<img src="{small_image}" align="left" style="border: 1px solid #000000; margin: 0px 5px 5px 0px"/>
</a>
</xsl:if>
<p>
<xsl:value-of disable-output-escaping="yes" select="description"/>
</p>
<!-- Цена товара -->
<strong>
<xsl:choose>
<xsl:when test="price != 0">
<xsl:value-of disable-output-escaping="yes" select="price"/> 
<!-- Валюта товара -->
<xsl:value-of disable-output-escaping="yes" select="currency"/>
</xsl:when>
<xsl:otherwise>договорная</xsl:otherwise>
</xsl:choose>
</strong>
<!-- Если цена со скидкой - выводим ее -->
<xsl:if test="price!=price_tax">
<br/>
<font color="gray">
<strike>
<xsl:value-of disable-output-escaping="yes" select="price_tax"/> <xsl:value-of disable-output-escaping="yes" select="currency"/></strike>
</font>
</xsl:if>
<!-- Если указан вес товара -->
<xsl:if test="weight != 0">
<br/>Вес товара: <xsl:value-of select="weight"/> <xsl:value-of select="weight_mesure"/></xsl:if>
<!-- Показываем скидки -->
<xsl:if test="count(discount) > 0">
<xsl:apply-templates select="discount"/>
</xsl:if>
<!-- Показываем количество на складе, если больше нуля -->
<xsl:if test="rest > 0">
<br/>В наличии: <xsl:value-of disable-output-escaping="yes" select="rest"/></xsl:if>
<xsl:if test="producer/name != ''">
<br/>Производитель: <xsl:value-of disable-output-escaping="yes" select="producer/name"/></xsl:if>
</div>
</xsl:template>
<!-- Шаблон выводит хлебные крошки -->
<xsl:template match="group" mode="goup_path">
<xsl:variable name="parent_id" select="@parent"/>
<!-- Выбираем рекурсивно вышестоящую группу -->
<xsl:apply-templates select="//group[@id=$parent_id]" mode="goup_path"/>
<xsl:if test="@parent=0">
<a href="{/shop/path}">
<xsl:value-of select="/shop/name"/>
</a>
</xsl:if>
<span class="path_arrow">→</span>
<a href="{/shop/path}{fullpath}">
<xsl:value-of select="name"/>
</a>
</xsl:template>
<!-- для размеров -->
<xsl:template match="modifications/item/property[@xml_name='razm_odez']">
<xsl:variable name="value" select="value" />
<xsl:choose>
<xsl:when test="position() = 1">
<input name="property133" size="20" type="radio" value="{/shop/properties_for_group/property[@xml_name='razm_odez']/list_items/list_item[list_item_value=$value]/@id}" checked=""/><xsl:value-of select="value"/><br />
</xsl:when>
<xsl:otherwise>
<input name="property133" size="20" type="radio" value="{/shop/properties_for_group/property[@xml_name='razm_odez']/list_items/list_item[list_item_value=$value]/@id}" /><xsl:value-of select="value"/><br />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- для ростов -->
<xsl:template match="modifications/item/property[@xml_name='rost']">
<xsl:variable name="value" select="value" />
<xsl:choose>
<xsl:when test="position() = 1">
<input name="property135" size="20" type="radio" value="{/shop/properties_for_group/property[@xml_name='rost']/list_items/list_item[list_item_value=$value]/@id}" checked="checked"/><xsl:value-of select="value"/><br />
</xsl:when>
<xsl:otherwise>
<input name="property135" size="20" type="radio" value="{/shop/properties_for_group/property[@xml_name='rost']/list_items/list_item[list_item_value=$value]/@id}" /><xsl:value-of select="value"/><br />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Корзина Цитата:
<?php
/* Создаем экземпляр класса магазина (при создании устанавливаем флаг необходимости очитстки кукисов в истину) */
$shop = & singleton('shop'
;/* Идентификатор интернет-магазина */
$shop_id = to_int($GLOBALS['LA']['shop_id']);
/**
* Использовать ли контроль данных, полученных из cookies
*/
// $shop->use_cookies_read_control = true;
// Обработка AJAX-запросов при заказе
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'get_location' && isset($_REQUEST['shop_country_id']))
{
$shop_country_id = to_int($_REQUEST['shop_country_id']);
$result = array();
if ($shop_country_id)
{
// Расположения заполняем только тогда, когда страна указана
$res = $shop->GetAllLocation($shop_country_id);
if ($res)
{
while ($row = mysql_fetch_assoc($res))
{
$result[$row['shop_location_id']] = $row['shop_location_name'];
}
}
}
$JsHttpRequest = new JsHttpRequest(SITE_CODING);
$GLOBALS['_RESULT'] = array(
'result' => $result);
echo $JsHttpRequest->LOADER;
exit();
}
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'get_city' && isset($_REQUEST['shop_location_id']))
{
$shop_location_id = to_int($_REQUEST['shop_location_id']);
$result = array();
if ($shop_location_id)
{
// Города заполняем только тогда, когда расположение указано
$res = $shop->GetAllCity($shop_location_id);
if ($res)
{
while ($row = mysql_fetch_assoc($res))
{
$result[$row['shop_city_id']] = $row['shop_city_name'];
}
}
}
$JsHttpRequest = new JsHttpRequest(SITE_CODING);
$GLOBALS['_RESULT'] = array(
'result' => $result);
echo $JsHttpRequest->LOADER;
exit();
}
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'get_cityarea' && isset($_REQUEST['shop_city_id']))
{
$shop_city_id = to_int($_REQUEST['shop_city_id']);
$result = array();
// Города заполняем только тогда, когда расположение указано
if ($shop_city_id)
{
$res = $shop->GetAllCityArea($shop_city_id);
if ($res)
{
while ($row = mysql_fetch_assoc($res))
{
$result[$row['shop_city_area_id']] = $row['shop_city_area_name'];
}
}
}
$JsHttpRequest = new JsHttpRequest(SITE_CODING);
$GLOBALS['_RESULT'] = array(
'result' => $result);
echo $JsHttpRequest->LOADER;
exit();
}
// END обработка AJAX-запросов при заказе
if (class_exists("SiteUsers"
){
/* Определяем идентификатор текущего пользователя */
$SiteUsers = & singleton('SiteUsers'
;$site_users_id = $SiteUsers->GetCurrentSiteUser();
}
else
{
$site_users_id = false;
}
// Повторение заказа
if (to_str($_REQUEST['action']) == 'repeat'

{
$shop_order_guid = to_str($_REQUEST['shop_order_guid']);
$order_row = $shop->GetOrderByGuid($shop_order_guid);
// Заказ найден
if ($order_row)
{
$shop_order_id = $order_row['shop_order_id'];
// Если заказ принадлежит этому пользователю
if ($order_row['site_users_id'] == $site_users_id && $site_users_id != 0)
{
$result_order_items = $shop->GetOrderItems($shop_order_id);
$shop_id_from_order = to_int($order_row['shop_shops_id']);
while ($row = mysql_fetch_assoc($result_order_items))
{
// Число товаров передаем, если посетитеь кладет в корзину больше одного товара
if (to_int( $row['shop_order_items_quantity']) > 0)
{
$count = to_int( $row['shop_order_items_quantity']);
}
/* Добавляем товар в корзину */
$shop->AddIntoCart(array('user_id' => $site_users_id,
'shop_id' => $shop_id_from_order,
'item_id' => $row['shop_items_catalog_item_id'],
'count' => $count));
}
}
}
}
// Запускаем сессию, если пользователь не авторизирован и пришли данные для регистрации
if ($site_users_id == 0 && isset($_POST['site_users_login'])
&& isset($_POST['site_users_password'])
&& isset($_POST['site_users_email'])
&& !isset($_SESSION))
{
session_start();
}
$GLOBALS['external_propertys'] = array();
// Если сессия не была запущена - стартуем ее
if (isset($_POST['step_1_1a']) && !isset($_SESSION) && !class_exists("SiteUsers"
){
@session_start();
}
/* Необходимо перенести товары из кукисов в сессию и очистить кукисы */
if ((isset($_POST['step_4']) || isset($_POST['step_1_1a'])) && !class_exists("SiteUsers"
){
/* Читаем массив из кукисов */
if (!empty($_COOKIE['CART']))
{
$session_cart = array();
$postpone_items = array();
$cart_from_cookies = $shop->GetCookieCart();
$items = to_array($cart_from_cookies[$shop_id]);
foreach ($items as $key => $value)
{
if ($value['shop_cart_flag_postpone'])
{
/* Оставляем товар в корзине кукисов */
$postpone_items[$key] = $value;
}
else
{
/* Добавляем в корзину сессии */
$session_cart[$key] = $value;
}
}
/* Добавляем данные в сессию */
$_SESSION['CART'][$shop_id] = $session_cart;
/* Если массив с отложенными товарами не пуст - сохраняем его в кукисы */
if (count($postpone_items) > 0 && isset($_POST['step_4']))
{
$cart_from_cookies[$shop_id] = $postpone_items;
}
elseif(isset($_POST['step_4']))
{
/* Удалям целиком кукисы карзины для данного магазина */
unset($cart_from_cookies[$shop_id]);
}
/* Сохраняем данные */
$shop->SetCookieCart($cart_from_cookies, time() + 31536000, '/'
;}
}
/* Переданы данные для авторизации */
if (isset($_POST['step1_1']))
{
/* Проверяем правильность введенных данных */
$site_users_id = $SiteUsers->ValidUser(to_str($_POST['login']), to_str($_POST['password']));
/* Проверяем подтвердил ли пользователь регистрацию */
if ($site_users_id == -1)
{
$GLOBALS['external_propertys']['error'] = -5; /* Вы не активировали свой аккаунт. По указанному адресу отправлено письмо с инструкцией об активации. После активации Вы можете авторизироваться. */
}
elseif ($site_users_id > 0)
{
// Пользователь ввел верные данные, авторизируем его
$SiteUsers->SetCurrentSiteUser($site_users_id);
}
else
{
/* Неверные данные пользователя */
$GLOBALS['external_propertys']['error'] = -6;
}
}
/* AJAX добавление товара в корзину */
if (isset ($_GET['ajax_add_item_id']))
{
$property_array = array ();
$key_property_array = array ();
if (isset ($_GET) && count($_GET))
{
foreach ($_GET as $key => $val)
{
if (preg_match("'^property([\d]*?)$'si", $key, $preg))
{
$property_array[$preg[1]] = $val;
}
}
}
$param = array ();
$param['shop_id'] = $shop_id;
$param['item_id'] = to_int($_GET['ajax_add_item_id']);
$param['user_id'] = $site_users_id;
// Все модификации товара
$all_modifications = $shop->GetAllModificationItems($param['item_id']);
if ($all_modifications)
{
foreach ($all_modifications as $key => $value)
{
$item_propertys_value = array ();
// Получаем значения всех доп.свойств
foreach ($property_array as $id => $v)
{
$list_property_value = $shop->GetValueItemProperty(to_int($value['shop_items_catalog_item_id']), $id);
// Получаем значение элемента списка
$item_propertys_value[$id] = to_int($list_property_value['shop_properties_items_value']);
}
// Если у модификации совпали все переданные свойства, возвращаем идентификатор модификации
$array_diff = array_diff_assoc($property_array, $item_propertys_value);
if (!count($array_diff))
{
$param['item_id'] = $value['shop_items_catalog_item_id'];
break;
}
}
}
// Число товаров передаем, если посетитеь кладет в корзину больше одного товара
if (to_int($_GET['count']) > 0)
{
$param['count'] = to_int($_GET['count']);
}
// Добавляем товар в корзину
$shop->AddIntoCart($param);
// Отображаем корзину
$JsHttpRequest = new JsHttpRequest(SITE_CODING);
ob_start();
$shop->ShowCart($shop_id, $site_users_id, to_str($GLOBALS['LA']['xsl_little_cart']));
$little_cart_html = ob_get_clean();
$GLOBALS['_RESULT'] = array (
'cart' => $little_cart_html
);
echo $JsHttpRequest->LOADER;
exit ();
}
/* добавление товара в корзину */
if (to_str($_GET['action']) == 'add'

{
$param = array();
$param['shop_id'] = $shop_id;
$param['item_id'] = to_int($_GET['item_id']);
$param['user_id'] = $site_users_id;
// Число товаров передаем, если посетитеь кладет в корзину больше одного товара
if (to_int($_GET['count']) > 0)
{
$param['count'] = to_int($_GET['count']);
}
/* Добавляем товар в корзину */
$shop->AddIntoCart($param);
}
/* Удаляение товара из корзины */
if (to_str($_GET['action']) == 'delete_item'

{
$param = array();
$param['shop_id'] = $shop_id;
$param['item_id'] = to_int($_GET['item_id']);
/* Проверяем наличие пользователя */
if ($site_users_id != 0)
{
$param['user_id'] = $site_users_id;
}
$shop->DeleteCart($param);
}
/* Пересчет товара в корзине */
if (isset($_POST['recount']))
{
$param = array();
foreach ($_POST as $key => $value)
{
$param['item_id'] = $key;
/* Получаем идентификатор записи в корзине по идентификатору пользователя и товара */
$cart_id = $shop->GetItemFromCart($shop_id, $site_users_id, $param['item_id']);
$param['cart_id'] = to_int($cart_id['shop_cart_id']);
$param['user_id'] = $site_users_id;
$param['shop_id'] = $shop_id;
$param['count'] = to_int($value);
/* Если установлен флажок - делаем товар отложенным */
$param['postpone'] = !empty($_POST['flag_postpone'.$key]) ? 1 : 0;
/* Если количество = 0 - удаляем из корзины */
if ($param['count'] == 0)
{
$shop->DeleteCart($param);
}
else
{
$shop->UpdateCart($param);
}
}
}
?>Цитата:
denisov999 писал(а):
Вот только не понимаю в <input name=«property133» size=«20“ value=“» type=«radio»>S<br> — Так и должно быть? я про значение value?
- нет, такого быть не должно. У вас, видимо, не последняя версия системы(т.к. в последней версии эта проблема решалась). Вам необходимо(как верно советовал DStorm), находясь в корне магазина(в разделе администрирования), выбрать меню "Товар" -> "Свойства товаров для группы" и включить доступность ваших доп. свойств(они у вас точно имеют идентификаторы 133 и 135?).1. Версия последняя 5.8.4.
2. natalya писал(а):
3. Да 133 и 135.
4.
2. natalya писал(а):
Вам необходимо(как верно советовал DStorm), находясь в корне магазина(в разделе администрирования), выбрать меню «Товар» -> «Свойства товаров для группы» и включить доступность ваших доп. свойств
- об этом уже писал что не помогает.3. Да 133 и 135.
4.
<input name="property133" size="20" value="" type="radio">S<br>
- А тут параметр S же берется из допсвойств модификации. Так что в принципе работает. Вот только Value не заполняется. А что там должно быть - параметр доп свойства как S? <input name="property133" size="20" type="radio" value="{/shop/properties_for_group/property[@xml_name='razm_odez']/list_items/list_item[list_item_value=$value]/@id}" /><xsl:value-of select="value"/><br />
- Из написаного выше. Я так понимаю
<xsl:value-of select="value"/>
- работает корректноА вот
value="{/shop/properties_for_group/property[@xml_name='razm_odez']/list_items/list_item[list_item_value=$value]/@id}"
ни как не хочет заполнятсяВ чем может быть дело?
Авторизация
Работаем c 9:00 до 18:00
Продолжая использовать сайт, вы даете согласие на обработку файлов куки и пользовательских данных на условиях политики обработки.
Возможности
Поддержка
О HostCMS
- Купить онлайн
- Скачать бесплатно
- Готовые сайты
- Готовые интернет-магазины
- Демо-версия
- Отзывы пользователей
© 2005—2026 ООО «Хостмэйк»
Мы используем куки и обработку пользовательских данных с помощью Яндекс.Метрики для лучшей работы сайта.
Оставаясь с нами, вы соглашаетесь на использование файлов куки.