Корзина на всех страницах сайта

#
Корзина на всех страницах сайта
Добрый день!

Возникла необходимость в использовании полной (не краткой) корзины на всех страницах сайта, вместо краткой корзины. Все вроде работает замечательно, все отображается как надо! Но не работают кнопки "удалить" и "пересчитать", работоспособность которых является самой важной частью данной задумки...

Т.е. пользователь должен иметь возможность не переходя в корзину (на любой странице сайта) посмотреть что лежит в корзине, увидеть цену, сумму, общую стоимость всех товаров. Должен иметь возможность изменить количество нужного ему товара (за счет соответствующих полей и кнопки "пересчитать" или удалить товар из корзины. Удаление было сделано, но при нажатии на кнопку "удалить" пользователь попадал на страницу корзины - такой исход ни в коем случае не нужен...

Итоги:
1. как осуществить удаление из корзины без перехода на другую страницу? Какой код вклеить в макет? Или может быть есть вариант с ajax?
2. как осуществить пересчет корзины? ЭТОТ ВОПРОС ВАЖНЕЕ!

Пример кода, который вставлен в основной макет сайта между <head>...</head>
<?php
/* Пересчет товара в корзине */
if (isset($_POST['recount'])
// Пересчет при выборе первого шага
|| isset($_POST['step_1']))
{
   $param = array();

   $warehouse = & singleton('warehouse');
   
   foreach ($_POST as $key => $value)
   {
      $param['item_id'] = $key;

      /* Получаем идентификатор записи в корзине по идентификатору пользователя и товара */
      $cart_id = $shop->GetItemFromCart($shop_id, $site_users_id, $param['item_id']);

      $shop_id = 1;
      $param['cart_id'] = to_int($cart_id['shop_cart_id']);
      $param['user_id'] = $site_users_id;
      $param['shop_id'] = $shop_id;
      $param['count'] = $value;
      
      if (isset($_POST['warehouse'.$key]))
      {
         $param['warehouse_id'] = $_POST['warehouse'.$key];
      }
      else
      {
         // Склад по умолчанию
         $param['warehouse_id'] = $warehouse->GetDefaultWarehouse($shop_id);
      }

      /* Если установлен флажок - делаем товар отложенным */
      $param['postpone'] = !empty($_POST['flag_postpone'.$key]) ? 1 : 0;

      /* Если количество = 0 - удаляем из корзины */
      if ($param['count'] == 0)
      {
         $shop->DeleteCart($param);
      }
      else
      {
         $shop->UpdateCart($param);
      }
   }
}
?>

возможно в нем ошибка?...

XML-шаблон корзины
<?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:variable name="recount" select="recount"/>
   
   <xsl:template match="/cart">
      <div id="little_cart">
         <xsl:choose>
            <!-- В корзине нет ни одного элемента -->
            <xsl:when test="totalquantity = 0">
               <xsl:choose>
                  <xsl:when test="site_users_class_exists = 1 and user_id = 0">
                     <p>Если Вы зарегистрированный пользователь, данные Вашей корзины станут видны после авторизации.</p>
                  </xsl:when>
                  <xsl:otherwise>
                     <div id="cart_top">
                        <img src="/images/my_cart.png" style="margin-top:18px; margin-left:18px;" />
                        <p style="margin-top:18px; margin-left:18px; font-size:11pt; font-family:Arial; text-decoration:underline;">ваша корзина пуста</p>
                        <img src="/images/carttop_but_p.png" style="position:absolute; top:19px; right:7px;" />
                     </div>
                     <div id="cartorg_bt"></div>
                     <div id="cartorg_bc">
                        <h2>РАСЧЕТ СТОИМОСТИ ВАШЕГО ПРОЕКТА &#8211;</h2>
                        <p>+ выберите камеры,<br />
                           + выберите регистратор,<br />
                        = получите стоимость с учетом <br />&#8194;&#8201;монтажных работ или без.</p>
                     </div>
                     <div id="cartorg_bb"></div>
                  </xsl:otherwise>
               </xsl:choose>
            </xsl:when>
            <xsl:otherwise>
               <!-- Вывод корзины -->
               <div id="cart_top">
                  <img src="/images/my_cart.png" style="margin-top:18px; margin-left:18px;" />
               <p style="margin-top:18px; margin-left:18px;"><a style="color:#000000; font-size:11pt; font-family:Arial; text-decoration:underline;" href="{/cart/shop/path}cart/">оформление заказа</a></p>
                  <a href="{/cart/shop/path}cart/"><img src="/images/carttop_but_a.png" style="position:absolute; top:19px; right:7px;" /></a>
               </div>
               <div id="cartorg_bt"></div>
               <div id="cartorg_bc">
                  <h2>РАСЧЕТ СТОИМОСТИ ВАШЕГО ПРОЕКТА &#8211;</h2>
                  <form action="/" name="address" method="POST">
                     <!-- Если есть товары -->
                     <xsl:if test="count(itemincart[flag_postpone = 0]) > 0">
                        <table cellspacing="0" cellpadding="0" border="0" class="shop_cart_table">
                           <tr>
                              <th>Товар</th>
                              <!--<td width="70">Вес</td>-->
                              <th width="70">Кол-во</th>
                              <th width="100">Цена</th>
                              <th width="100">Сумма</th>
                           </tr>
                           <xsl:apply-templates select="itemincart[flag_postpone = 0]"/>
                           <tr class="shop_cart_table">
                              <td>
                                 <b>Итого:</b>
                              </td>
                              <td>
                                 <b>
                                    <xsl:value-of disable-output-escaping="yes" select="totalquantity"/>
                                 </b>
                              </td>
                              <td>&#xA0;</td>
                              <td style="white-space: nowrap">
                                 <xsl:value-of select="format-number(total_sum_without_discount,'### ##0', 'my')"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="shop/shop_currency/shop_currency_name"/>
                              </td>
                              
                              <xsl:if test="/cart/shop/warehouses/node()">
                                 <td>&#xA0;</td>
                              </xsl:if>
                              
                              <td>&#xA0;</td>
                              <td>&#xA0;</td>
                           </tr>
                           <xsl:if test="total_sum_without_discount &gt; totalsum">
                              <tr class="shop_cart_table">
                                 <!--<td style="border-bottom: thin dashed #DADADA">
                                    &#xA0;
                                 </td>-->
                                 <td style="border-bottom: thin dashed #DADADA">
                                    <b>Скидка:</b>
                                 </td>
                                 <td style="border-bottom: thin dashed #DADADA">&#xA0;</td>
                                 <td style="border-bottom: thin dashed #DADADA">&#xA0;</td>
                                 <td style="border-bottom: thin dashed #DADADA; white-space: nowrap; font-weight: bold">
                                    <b>
                                       <xsl:value-of disable-output-escaping="yes" select="format-number(total_sum_without_discount - totalsum, '### ##0,00', 'my')"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="shop/shop_currency/shop_currency_name"/></b>
                                 </td>
                                 <xsl:if test="/cart/shop/warehouses/node()">
                                    <td style="border-bottom: thin dashed #DADADA">&#xA0;</td>
                                 </xsl:if>
                                 <td style="border-bottom: thin dashed #DADADA">&#xA0;</td>
                                 <td style="border-bottom: thin dashed #DADADA">&#xA0;</td>
                              </tr>
                              <tr class="shop_cart_table">
                                 <!--<td style="border-bottom: none">
                                    &#xA0;
                                 </td>-->
                                 <td style="border-bottom: none">
                                    <b>Всего:</b>
                                 </td>
                                 <td style="border-bottom: none">&#xA0;</td>
                                 <td style="border-bottom: none">&#xA0;</td>
                                 <td style="border-bottom: none; white-space: nowrap; font-weight: bold">
                                    <xsl:value-of disable-output-escaping="yes" select="format-number(totalsum, '### ##0,00', 'my')"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="shop/shop_currency/shop_currency_name"/>
                                 </td>
                                 <td style="border-bottom: none">&#xA0;</td>
                                 <xsl:if test="/cart/shop/warehouses/node()">
                                    <td style="border-bottom: none">&#xA0;</td>
                                 </xsl:if>
                                 <td style="border-bottom: none">&#xA0;</td>
                                 <td style="border-bottom: none">&#xA0;</td>
                              </tr>
                           </xsl:if>
                        </table>
                        
                        <div style="clear: both; height: 20px;"></div>
                     </xsl:if>
                     
                     <!-- Кнопки -->
                     <div class="gray_button">
                        <div>
                           <input name="recount" value="Пересчитать" type="submit" />
                        </div>
                     </div>
                     
                  </form>
               </div>
               <div id="cartorg_bb"></div>
            </xsl:otherwise>
         </xsl:choose>
      </div>
   </xsl:template>
   
   <!-- Шаблон для товара в корзине -->
   <xsl:template match="itemincart">
      <tr class="shop_cart_table">
         
         <td style="font-size: 120%;">
            
            <a href="{/cart/shop/path}{item/fullpath}{item/path}/">
               <xsl:value-of disable-output-escaping="yes" select="item/name"/>
            </a>
            <!--=<xsl:value-of select="/cart/shop/shop_list_of_prices//shop_list_of_price[@id = shop_list_of_prices_for_item//[shop_list_of_price_for_item = price_discount]/@id]/percent" />=-->
            <!--
            <xsl:if test="item/small_image!=''">
               <img src="{item/small_image}"/>
            </xsl:if>
            -->
            
            
            <div style="clear: both"></div>
         </td>
         <td style="white-space: nowrap">
            <input type="text" size="3" name="{item/@id}" id="count_{item/@id}" value="{quantity}"/>
            
            <img src="/images/map_intocart.gif" width="12" height="21" border="0" usemap="#mapInToCart{item/@id}" style="margin: 0 0 -6px 1px;"/>&#xA0;<xsl:value-of select="item/mesure" disable-output-escaping="yes"/>
            
            <map name="mapInToCart{item/@id}">
               <area shape="rect" coords="0,0,12,10"  onclick="set_count_mod('count_{item/@id}', 1);" nohref="nohref" />
               <area shape="rect" coords="0,11,12,21" onclick="set_count_mod('count_{item/@id}', -1);" nohref="nohref" />
            </map>
            
            
         </td>
         <td style="white-space: nowrap">
            <!-- Цена -->
            <xsl:value-of disable-output-escaping="yes" select="format-number(item/price_discount, '### ##0', 'my')"/>&#xA0;<xsl:value-of select="item/currency" disable-output-escaping="yes"/></td>
         
         <td style="white-space: nowrap">
            <!-- Сумма -->
            <xsl:value-of disable-output-escaping="yes" select="format-number(item/price_discount * quantity, '### ##0', 'my')"/>&#xA0;<xsl:value-of disable-output-escaping="yes" select="item/currency"/></td>
         
      <td align="center"><a href="?action=delete_item&amp;item_id={item/@id}" onclick="return confirm('Вы уверены, что хотите удалить?');" title="Удалить товар из корзины" alt="Удалить товар из корзины">Удалить</a></td>
      </tr>
   </xsl:template>
   
</xsl:stylesheet>


Если кто-либо сталкивался с подобной ситуацией помогите, пожалуйста! Возможно за какую-либо плату...
FobosMIX
Авторизация