Цена модификации

#
Цена модификации
У меня сделаны товары с модификациями, по цвету , по размеру
на странице товара покупатель из выпадающего списка выбирает нужный цвет и/или размер, цена на конкретную модификацию может отличаться
в корзину добавляется цена отличная от цены товара (т.е. все правильно)
НО как сделать так чтобы если покупатель выбирает мышкой например другой цвет и цена на него другая, то цена рядом с товаром менялась бы сразу? чтоб было видно что другая цена

Email: golden-puma@yandex.ru; Telegram: @GoldenPuma; Сайт: https://goldenpuma.ru
#
Re: Цена модификации
можно так
http://medvejonok.com/summer/art-133-41-24-04/
из всех товаров формируется js массив
modId['ID доп. свойства цвет - Разделитель - Размер'] = [ID модификации,Цена,Количество на складе];
например
modId['75s29'] = [281,'2 070',5,'0'];

при выборе цвета и размера из аттрибутов склеивается название объекта и его цена подставляется в span для цены
#
Re: Цена модификации
не вижу чтоб на указанном вами сайте менялась цена от размера
http://medvejonok.com/summer/art-133-41-24-04/
вижу только что цвет меняется
Email: golden-puma@yandex.ru; Telegram: @GoldenPuma; Сайт: https://goldenpuma.ru
#
Re: Цена модификации
цвет синий - размер 30 например
#
Re: Цена модификации
теперь понятно (цвет выбрать не догадалась)
вижу у вас в коде сайта данный скрипт
а как мне его заиметь?
Email: golden-puma@yandex.ru; Telegram: @GoldenPuma; Сайт: https://goldenpuma.ru
#
Re: Цена модификации
цвет и размер сделаны доп свойствами списками

в xsl код такой

<xsl:template match="item">

...

<script>
$(document).ready(function(){

   var modId = {};
   <xsl:apply-templates select="modifications/item[name!='']" mode="script"/>

   $('.cartLoad').css('top','0').hide();

   $("a.buttonCart").click(function () {
      if ($(this).hasClass('disabled')){
if ($('.itemColor .active').length == 0 <xsl:text disable-output-escaping="yes">&amp;&amp;</xsl:text> $('.itemSize .active').length == 0) {
alert('Пожалуйста, выберите цвет и размер изделия');
}
else if ($('.itemColor .active').length == 0 <xsl:text disable-output-escaping="yes">&amp;&amp;</xsl:text> $('.itemSize .active').length <xsl:text disable-output-escaping="yes">&gt;</xsl:text> 0) {
alert('Пожалуйста, выберите цвет изделия');
}
else if ($('.itemColor .active').length <xsl:text disable-output-escaping="yes">&gt;</xsl:text> 0 <xsl:text disable-output-escaping="yes">&amp;&amp;</xsl:text> $('.itemSize .active').length == 0) {
alert('Пожалуйста, выберите размер изделия');
}
return false

} else {var iditem = $(this).attr('data-cart'); return AddIntoCart('/cart/', iditem, 1);}
   });

   $(".shopSingleItemVariants li").click(function () {
      if ($(this).hasClass('active') || $(this).hasClass('unavailable')){return false}
      $(this).parent().find('li').removeClass('active');
      $(this).addClass('active');

      var icolor = $('.itemColor .active').attr('data-item')+'';
      var isize = $('.itemSize .active').attr('data-item')+'';

      if ($(this).parent().hasClass('itemColor')) {
            $('.unavailable').attr('title','');
            $('.itemSize li').removeClass('unavailable');
            $.each(modId, function(key, value) {
            var str = icolor+'s';
            if (key.indexOf(str) != -1) {
               if (modId[key][2] == 0) {
                  $('.itemSize li[data-item='+key.substr(str.length)+']').removeClass('active').addClass('unavailable');
               }
            }
            });
            $('.unavailable').attr('title','Нет в наличии');
      }

      if ($(this).parent().hasClass('itemSize')) {
            $('.unavailable').attr('title','');
            $('.itemColor li').removeClass('unavailable');
            $.each(modId, function(key, value) {
            var str = 's'+isize;
            var s = 's';
            if (key.indexOf(str) != -1) {
               if (modId[key][2] == 0) {

                  $('.itemColor li[data-item='+key.substring(0,key.indexOf(s))+']').removeClass('active').addClass('unavailable');
               }
            }
            });
            $('.unavailable').attr('title','Нет в наличии');
      }

      if ($('.itemColor .active').length <xsl:text disable-output-escaping="yes">&gt;</xsl:text> 0 <xsl:text disable-output-escaping="yes">&amp;&amp;</xsl:text> $('.itemSize .active').length <xsl:text disable-output-escaping="yes">&gt;</xsl:text> 0) {
         var idcart = modId[icolor + 's' + isize][0];
         $('#priceChange').html(modId[icolor + 's' + isize][1]);
         if (modId[icolor + 's' + isize][3]!='0') {
            $('#priceChangeDiscount').html(modId[icolor + 's' + isize][3]);
         }
         $('a.buttonCart').attr({
            'data-cart': idcart,
            'href': '/cart/?action=add<xsl:text disable-output-escaping="yes">&amp;</xsl:text>item_id='+idcart
         });
         if (modId[icolor + 's' + isize][2] == 0) {
            $('a.buttonCart').addClass('disabled');
         }
         else {
            $('a.buttonCart').removeClass('disabled');
         }
      }
      else {
         $('a.buttonCart').addClass('disabled');
      }
   });
});
</script>

...

</xsl:template>

<xsl:template match="modifications/item" mode="script">
<xsl:variable name="colorname" select="property[@xml_name='color']/value"/>
<xsl:variable name="pricetax">
<xsl:choose>
<xsl:when test="price_tax != price_discount"><xsl:value-of select="format-number(price_tax, '### ##0', 'my')"/></xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
modId['<xsl:value-of select="/shop/properties_for_group/property[@xml_name='color']/list_items/list_item[list_item_value=$colorname]/@id"/>s<xsl:value-of select="property[@xml_name='size']/value"/>'] = new Object();
modId['<xsl:value-of select="/shop/properties_for_group/property[@xml_name='color']/list_items/list_item[list_item_value=$colorname]/@id"/>s<xsl:value-of select="property[@xml_name='size']/value"/>'] = [<xsl:value-of select="@id"/>,'<xsl:value-of select="format-number(price_discount, '### ##0', 'my')"/>',<xsl:value-of select="format-number(rest, '### ##0', 'my')"/>,'<xsl:value-of select="$pricetax"/>'];
</xsl:template>


Только нужно убрать лишнее и переделать все события под выпадающие списки
вместо
$(".shopSingleItemVariants li").click(function () {
-
$(".class").change(function () {

вместо
var icolor = $('.itemColor .active').attr('data-item')+'';
var isize = $('.itemSize .active').attr('data-item')+'';
-
var icolor = $('.itemColor option:selected').attr('data-item')+'';
var isize = $('.itemSize option:selected').attr('data-item')+'';


и нужно прописать для каждого option в цветах и размерах параметр data-item
<xsl:template match="modifications/item/property[@xml_name='color']">
..
<xsl:variable name="cvalue" select="value"/>
<option data-item="{/shop/properties_for_group/property[@xml_name='color']/list_items/list_item[list_item_value=$cvalue]/@id}" value="...">
..
</xsl:template>


то есть ID элемента из списка цветов-размеров
#
Re: Цена модификации
вроде сделала, но ничего не меняется (вот тут посмотреть http://test.dollystyle.ru/shop/group_615/item_454/)
вот мой xsl шаблон
<?xml version="1.0" encoding="utf-8"?>
<!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="utf-8" indent="yes" method="html" omit-xml-declaration="no" version="1.0" media-type="text/xml"/>
   
   <xsl:decimal-format name="my" decimal-separator="," grouping-separator=" "/>
   
   <xsl:key name="property133" match="/shop/item/modifications/item/property[@xml_name='size']" use="value"/>
   <xsl:key name="property134" match="/shop/item/modifications/item/property[@xml_name='color']" 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 GetSelectValue(selectName)
               
               {
               
               value=document.getElementById(selectName).value;
               
               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>
<!--скрипт смены цены для модификаций-->
         <script>
$(document).ready(function(){

   var modId = {};
   <xsl:apply-templates select="modifications/item[name!='']" mode="script"/>

   $('.cartLoad').css('top','0').hide();

   $("a.buttonCart").click(function () {
      if ($(this).hasClass('disabled')){
if ($('.itemColor .active').length == 0 <xsl:text disable-output-escaping="yes">&amp;&amp;</xsl:text> $('.itemSize .active').length == 0) {
alert('Пожалуйста, выберите цвет и размер изделия');
}
else if ($('.itemColor .active').length == 0 <xsl:text disable-output-escaping="yes">&amp;&amp;</xsl:text> $('.itemSize .active').length <xsl:text disable-output-escaping="yes">&gt;</xsl:text> 0) {
alert('Пожалуйста, выберите цвет изделия');
}
else if ($('.itemColor .active').length <xsl:text disable-output-escaping="yes">&gt;</xsl:text> 0 <xsl:text disable-output-escaping="yes">&amp;&amp;</xsl:text> $('.itemSize .active').length == 0) {
alert('Пожалуйста, выберите размер изделия');
}
return false

} else {var iditem = $(this).attr('data-cart'); return AddIntoCart('/cart/', iditem, 1);}
   });

   $(".class").change(function () {
      if ($(this).hasClass('active') || $(this).hasClass('unavailable')){return false}
      $(this).parent().find('li').removeClass('active');
      $(this).addClass('active');

var icolor = $('.itemColor option:selected').attr('data-item')+'';
var isize = $('.itemSize option:selected').attr('data-item')+'';

      if ($(this).parent().hasClass('itemColor')) {
            $('.unavailable').attr('title','');
            $('.itemSize li').removeClass('unavailable');
            $.each(modId, function(key, value) {
            var str = icolor+'s';
            if (key.indexOf(str) != -1) {
               if (modId[key][2] == 0) {
                  $('.itemSize li[data-item='+key.substr(str.length)+']').removeClass('active').addClass('unavailable');
               }
            }
            });
            $('.unavailable').attr('title','Нет в наличии');
      }

      if ($(this).parent().hasClass('itemSize')) {
            $('.unavailable').attr('title','');
            $('.itemColor li').removeClass('unavailable');
            $.each(modId, function(key, value) {
            var str = 's'+isize;
            var s = 's';
            if (key.indexOf(str) != -1) {
               if (modId[key][2] == 0) {

                  $('.itemColor li[data-item='+key.substring(0,key.indexOf(s))+']').removeClass('active').addClass('unavailable');
               }
            }
            });
            $('.unavailable').attr('title','Нет в наличии');
      }

      if ($('.itemColor .active').length <xsl:text disable-output-escaping="yes">&gt;</xsl:text> 0 <xsl:text disable-output-escaping="yes">&amp;&amp;</xsl:text> $('.itemSize .active').length <xsl:text disable-output-escaping="yes">&gt;</xsl:text> 0) {
         var idcart = modId[icolor + 's' + isize][0];
         $('#priceChange').html(modId[icolor + 's' + isize][1]);
         if (modId[icolor + 's' + isize][3]!='0') {
            $('#priceChangeDiscount').html(modId[icolor + 's' + isize][3]);
         }
         $('a.buttonCart').attr({
            'data-cart': idcart,
            'href': '/cart/?action=add<xsl:text disable-output-escaping="yes">&amp;</xsl:text>item_id='+idcart
         });
         if (modId[icolor + 's' + isize][2] == 0) {
            $('a.buttonCart').addClass('disabled');
         }
         else {
            $('a.buttonCart').removeClass('disabled');
         }
      }
      else {
         $('a.buttonCart').addClass('disabled');
      }
   });
});
</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">&#x2192;</span>
         <b>
            <a href="{/path}">
               <xsl:value-of disable-output-escaping="yes" select="name"/>
            </a>
         </b>
         
         
         
         
         
         <!-- Информация об ошибках -->
         <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 class="product-outer">
            <div class="product">
               <div class="left-block">
                  <div  class="rating" >
                     <!-- Средняя оценка товара -->
                     <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>
                  <!-- Изображение для товара, если есть -->
                  <xsl:if test="small_image != ''">
                     <div id="gallery" style="float: left; width: {small_image/@width}px; margin: 0px 25px 10px 0px; color: #aaaaaa;">
                        <a href="{image}" target="blank_" >
                           <img src="{small_image}" style="margin: 0px 15px 5px 0px"/>
                        </a>
                        <br/>
                        <a href="{image}" target="blank_" >
                           <img src="/hostcmsfiles/images/zoom.gif" style="border: none;" alt="Увеличить" />
                           <a href="{image}" target="blank_" >Увеличить</a>
                        </a>
                     </div>
                  </xsl:if>
               </div>
               <div class="right-block">
                  <div style="width: 350px; height: {small_image/@height}px; float: left; ">
                     <!-- Цена товара -->
                     <p >Цена:
                        <span style="font-size: 11pt; font-weight: bold">
                           <xsl:choose>
                              <xsl:when test="price_discount != 0">
                                 <xsl:value-of select="format-number(price_discount, '### ###,00', 'my')"/>&#xA0;<xsl:value-of select="currency" disable-output-escaping="yes"/>
                              </xsl:when>
                              <xsl:otherwise>договорная</xsl:otherwise>
                           </xsl:choose>
                        </span>
                        <br/>
                        
                        <!-- Если цена со скидкой - выводим ее -->
                        <xsl:if test="price_tax != price_discount">
                           <span style="color: gray; text-decoration: line-through;">
                              <xsl:variable name="price_tax" select="price_tax"/>
                              <span style="font-size: 11pt">
                                 <xsl:value-of select="format-number($price_tax, '### ###,00', 'my')"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="currency"/></span>
                           </span>
                           <br/>
                        </xsl:if>
                     </p>
                     
                     
                     <xsl:choose>
                        <xsl:when test="modifications/item/property[@xml_name='size']/node() or modifications/item/property[@xml_name='color']/node()">
                           
                           <!-- Ссылку на добавление в корзины выводим, если:
                           type = 0 - простой тип товара
                           type = 1 - электронный товар, при этом остаток на складе больше 0 или -1,
                           что означает неограниченное количество -->
                           <xsl:if test="type = 0 or (type = 1 and (eitem_count > 0 or eitem_count = -1))">
            <table cellpadding="3" width="350px" cellspacing="3" border="0"><tr style="font-weight: bold;"><td>Кол-во</td><td><xsl:if test="modifications/item/property[@xml_name='size']/node()">Размер</xsl:if></td><td><xsl:if test="modifications/item/property[@xml_name='color']/node()">Цвет</xsl:if></td><td></td></tr>
                                 <tr><td width="65px">
                                       <input type="text" size="3" value="1" id="count_{@id}"/>
                                       <img src="/images/map_intocart.gif" width="12" height="21" border="0" usemap="#mapInToCart{@id}" style="margin: 0 0 -6px 1px;"/>
                                       <map name="mapInToCart{@id}">
                                          <area shape="rect" coords="0,0,12,10"  onclick="set_count_mod('count_{@id}', 1);" nohref="nohref" />
                                          <area shape="rect" coords="0,11,12,21" onclick="set_count_mod('count_{@id}', -1);" nohref="nohref" />
                                       </map>
                                       
                                    </td>
                                    <td>   <!-- размер --><xsl:if test="modifications/item/property[@xml_name='size']/node()">
                                          
                                          
                                          <select name="property133" id="property133">
                                             
                                             <xsl:apply-templates select="modifications/item/property[@xml_name='size' and
                                                generate-id(.)=generate-id(key('property133', value))]"/>
                                          </select>
                                    </xsl:if>               </td><td>
                                       <!-- цвет -->
                                       <xsl:if test="modifications/item/property[@xml_name='color']/node()">
                                          
                                          
                                          <select name="property134" id="property134">
                                             
                                             <xsl:apply-templates select="modifications/item/property[@xml_name='color' and
                                                generate-id(.)=generate-id(key('property134', value))]"/>
                                          </select>
                                          
                                    </xsl:if>   </td>
                                    <td>
                                       <xsl:choose>
                                          <!--Если есть два разных свойства цвет и размер-->
                                          <xsl:when test="modifications/item/property[@xml_name='size']/node() and modifications/item/property[@xml_name='color']/node()">
                                             <a href="{/shop/path}cart/?action=add&amp;item_id={@id}" onclick="return AddIntoCart('{/shop/path}', {@id}, document.getElementById('count_{@id}').value + '&amp;property134=' + GetSelectValue('property134')+ '&amp;property133=' + GetSelectValue('property133'))"
                                                style="text-decoration: none;">
                                                <img alt="В корзину" title="В корзину" src="/hostcmsfiles/images/cart.gif" style="margin: 0px 0px -4px 10px"/>В корзину</a>
                                          </xsl:when>
                                          <xsl:otherwise> <!--Если есть только одно свойство цвет или размер-->
                                             <xsl:if test="modifications/item/property[@xml_name='size']/node()">
                                                <a href="{/shop/path}cart/?action=add&amp;item_id={@id}" onclick="return AddIntoCart('{/shop/path}', {@id}, document.getElementById('count_{@id}').value + '&amp;property133=' + GetSelectValue('property133'))"
                                                   style="text-decoration: none;">
                                                   <img alt="В корзину" title="В корзину" src="/hostcmsfiles/images/cart.gif" style="margin: 0px 0px -4px 10px"/>В корзину</a>
                                             </xsl:if>
                                             <xsl:if test="modifications/item/property[@xml_name='color']/node()">
                                                <a href="{/shop/path}cart/?action=add&amp;item_id={@id}" onclick="return AddIntoCart('{/shop/path}', {@id}, document.getElementById('count_{@id}').value + '&amp;property134=' + GetSelectValue('property134'))"
                                                   style="text-decoration: none;">
                                                   <img alt="В корзину" title="В корзину" src="/hostcmsfiles/images/cart.gif" style="margin: 0px 0px -4px 10px"/>В корзину</a>
                                             </xsl:if>
                                       </xsl:otherwise></xsl:choose>
                                       <!--<a href="{/shop/path}cart/?action=add&amp;item_id={@id}" onclick="return AddIntoCart('{/shop/path}', {@id}, document.getElementById('count_{@id}').value + '&amp;property133=' + GetSelectValue('property133'))" style="text-decoration: none;">
                                          <img alt="В корзину" title="В корзину" src="/hostcmsfiles/images/cart.gif" style="margin: 0px 0px -4px 10px" />В корзину
                                       </a>
                                       -->
                           </td></tr></table></xsl:if>
                           
                           
                           
                           
                        </xsl:when>
                        <xsl:otherwise>
                           <table><tr><td>
                                    <input type="text" size="3" value="1" id="count_{@id}"/>
                                    <img src="/images/map_intocart.gif" width="12" height="21" border="0" usemap="#mapInToCart{@id}" style="margin: 0 0 -6px 1px; "/>
                                    <map name="mapInToCart{@id}">
                                       <area shape="rect" coords="0,0,12,10"  onclick="set_count_mod('count_{@id}', 1);" nohref="nohref" />
                                       <area shape="rect" coords="0,11,12,21" onclick="set_count_mod('count_{@id}', -1);" nohref="nohref" />
                                 </map></td><td><a href="{/shop/path}cart/?action=add&amp;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></td></tr></table>
                           
                        </xsl:otherwise>
                     </xsl:choose>
                     
                     
                     <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/shop_producers_list_name != ''">
                     <p>Производитель: <b><xsl:value-of disable-output-escaping="yes" select="producer/shop_producers_list_name"/></b></p>
                     </xsl:if>
                     
                     <!-- Если указан вес товара -->
                     <xsl:if test="weight != 0">
                        <p>Вес товара: <xsl:value-of select="weight"/>&#xA0;<xsl:value-of select="weight_mesure"/></p>
                     </xsl:if>
                     
                     <!-- Показываем скидки -->
                     <xsl:if test="count(discount) &gt; 0">
                        <xsl:apply-templates select="discount"/>
                     </xsl:if>
                     
                     <!-- Показываем количество на складе, если больше нуля -->
                     <xsl:if test="rest &gt; 0">
                        <p>В наличии: <xsl:value-of disable-output-escaping="yes" select="rest"/>&#xA0;<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>
                  </div>
                  
            </div>      <div class="clear"></div>   <div style="float: left; position: relative; "><!-- Текст товара -->
                  <p>
                     <xsl:value-of disable-output-escaping="yes" select="text"/>
               </p></div>
               <div style="float: left; width:100%;">
                  <xsl:if test="count(property) > 0">
                     <h2>Дополнительные фото</h2>
                     
                     <!-- Свойства в корневой группе -->
                     <xsl:if test="count(property[@dir_id = 0])">
                        <table border="0" width="100%" class="gallery"><tr>
                              <xsl:apply-templates select="property[@dir_id = 0]"/>
                           </tr>
                        </table>
                     </xsl:if>
                     
                     <!-- Выбираем список групп свойств -->
                     <xsl:apply-templates select="/shop/properties_items_dir"/>
                  </xsl:if>
                  
                  
                  <p style="padding-top: 10px;">
                     <h2>Другие товары для вашего любимца</h2>
                  </p>
                  <xsl:value-of disable-output-escaping="yes" select="/shop/tying_items"/>
            </div>               </div>
            
            
            
            
            
         </div>
         
         <!-- Тэги для информационного элемента -->
         <xsl:if test="count(tags/tag) &gt; 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=134]/node())]) &gt; 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=134]/node())]"/>
               </table>
            </div>
         </xsl:if>
         <br/>
         <xsl:if test="count(tying/item) &gt; 0">
            <p>
               <b>Сопутствующие товары:</b>
            </p>
            <!-- Отображаем сопутствующие товары -->
            <xsl:apply-templates select="tying/item"/>
            <div style="clear: both;"></div>
         </xsl:if>
         <br/><div>
            <!-- Отзывы о товаре -->
            <xsl:if test="count(comments/comment) &gt; 0">
               <p style="display: block; margin-top: 30px;" class="title">
               <a name="comments"></a>Отзывы о товаре:</p>
               <xsl:apply-templates select="comments/comment" />
            </xsl:if>
         </div>
         <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}&amp;height=30&amp;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 file_path != ''">
            
            
            <td style="padding: 5px; width: 33%;" align="center" >
               <xsl:choose>
                  <xsl:when test="type = 1">
                     <a href="{file_path}" ><img src="{small_image/file_path}" class="image"/></a>
                  </xsl:when>
                  
                  
                  <xsl:otherwise>
                     
                  </xsl:otherwise>
               </xsl:choose>
            </td>
            
      <xsl:if test="position() mod 3 = 0"> <tr></tr> </xsl:if>               </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>&#xA0;
      </xsl:template>
      
      <!-- Шаблон для модификаций -->
      <xsl:template match="modifications/item" mode="script">
<xsl:variable name="colorname" select="property[@xml_name='color']/value"/>
<xsl:variable name="pricetax">
<xsl:choose>
<xsl:when test="price_tax != price_discount"><xsl:value-of select="format-number(price_tax, '### ##0', 'my')"/></xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
modId['<xsl:value-of select="/shop/properties_for_group/property[@xml_name='color']/list_items/list_item[list_item_value=$colorname]/@id"/>s<xsl:value-of select="property[@xml_name='size']/value"/>'] = new Object();
modId['<xsl:value-of select="/shop/properties_for_group/property[@xml_name='color']/list_items/list_item[list_item_value=$colorname]/@id"/>s<xsl:value-of select="property[@xml_name='size']/value"/>'] = [<xsl:value-of select="@id"/>,'<xsl:value-of select="format-number(price_discount, '### ##0', 'my')"/>',<xsl:value-of select="format-number(rest, '### ##0', 'my')"/>,'<xsl:value-of select="$pricetax"/>'];
         <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_discount"/>&#xA0;
               <!-- Валюта -->
               <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 &gt; ceiling($current_grade))">
               
               <xsl:if test="$current_grade - 1 &gt; 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 &gt; ceiling($current_grade))">
               
               <xsl:if test="$current_grade - 0.5 &gt; 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>&#xA0;
         <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 &gt; $i and $n &gt; 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>&#xA0;·&#xA0;<xsl:value-of select="date_time"/>&#xA0;·&#xA0;<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"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="value"/>%
         </p>
      </xsl:template>
      
      <xsl:template match="tying/item">
         
         
         <div style="float: left; margin-right: 20px;">
            <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 #c16bb2; margin: 5px 5px 5px 0px"/>
               </a>
               
            </xsl:if>
            
            
            <p>
               <xsl:value-of disable-output-escaping="yes" select="description"/>
            </p>
            
            <!-- Цена товара -->
            <strong>
               <xsl:choose>
                  <xsl:when test="price_discount != 0">
                     <xsl:value-of disable-output-escaping="yes" select="price_discount"/>&#xA0;
                     <!-- Валюта товара -->
                     <xsl:value-of disable-output-escaping="yes" select="currency"/>
                  </xsl:when>
                  <xsl:otherwise>договорная</xsl:otherwise>
               </xsl:choose>
            </strong>
            
            <!-- Если цена со скидкой - выводим ее -->
            <xsl:if test="price_tax != price_discount">
               <br/>
               <font color="gray">
                  <strike>
                     <xsl:value-of disable-output-escaping="yes" select="price_tax"/>&#xA0;<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) &gt; 0">
               <xsl:apply-templates select="discount"/>
            </xsl:if>
            
            <!-- Показываем количество на складе, если больше нуля -->
            <xsl:if test="rest &gt; 0">
               <br/>В наличии: <xsl:value-of disable-output-escaping="yes" select="rest"/></xsl:if>
            
            <xsl:if test="producer/shop_producers_list_name != ''">
               <br/>Производитель: <xsl:value-of disable-output-escaping="yes" select="producer/shop_producers_list_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">&#x2192;</span>
         
         <a href="{/shop/path}{fullpath}">
            <xsl:value-of select="name"/>
         </a>
      </xsl:template>
      
      <!-- для размеров -->
      <xsl:template match="modifications/item/property[@xml_name='size']">
         <xsl:variable name="value" select="value" />
         <option data-item="{/shop/properties_for_group/property[@xml_name='size']/list_items/list_item[list_item_value=$cvalue]/@id}" value="{/shop/properties_for_group/property[@xml_name='size']/list_items/list_item[list_item_value=$value]/@id}"><xsl:value-of select="value"/></option>
      </xsl:template>
      <!-- для ростов -->
      <xsl:template match="modifications/item/property[@xml_name='color']">
         <xsl:variable name="value" select="value" />
         <option data-item="{/shop/properties_for_group/property[@xml_name='color']/list_items/list_item[list_item_value=$cvalue]/@id}" value="{/shop/properties_for_group/property[@xml_name='color']/list_items/list_item[list_item_value=$value]/@id}" ><xsl:value-of select="value"/></option>
      </xsl:template>
      
   </xsl:stylesheet>
Email: golden-puma@yandex.ru; Telegram: @GoldenPuma; Сайт: https://goldenpuma.ru
#
Re: Цена модификации
h4mpy, прошу помощи... подскажи что исправить?
Email: golden-puma@yandex.ru; Telegram: @GoldenPuma; Сайт: https://goldenpuma.ru
Авторизация