Ver Mensaje Individual
  #5 (permalink)  
Antiguo 05/05/2009, 10:03
Avatar de kimmy
kimmy
 
Fecha de Ingreso: julio-2008
Mensajes: 841
Antigüedad: 15 años, 9 meses
Puntos: 15
cómo hago para que cuando agregue el nuevo producto también agregue 1 a items???

Esta es mi función mostrar_carro:

Código PHP:
<?
function mostrar_carro($cart$change true$images 2)
{
  global 
$items;
  global 
$total_price;

  echo 
"<table border = 0 width = 100% cellspacing = 0>
        <form action = show_cart.php method = post>
        <tr><th colspan = "
. (1+$images) ." bgcolor=\"#D0E0F0\">Item/Tienda</th>
        <th bgcolor=\"#D0E0F0\">Precio</th>
        <th bgcolor=\"#D0E0F0\">Cantidad</th>
        <th bgcolor=\"#D0E0F0\">Total</th></tr>"
;
  
//display each item as a table row
  
foreach ($cart as $sku => $qty)
  {
    
$product get_product_details($sku);
    echo 
"<tr>";
    if(
$images ==true)
    {
      echo 
"<td align = left>";
      if (
file_exists("img/$sku.jpg"))
      {
         
$size GetImageSize("img/".$sku.".jpg");
         if(
$size[0]>&& $size[1]>0)
         {
           echo 
"<img src=\"img/".$sku.".jpg\" border=0 ";
           echo 
"width = "$size[0]/." height = " .$size[1]/">";
         }
      }
      else
         echo 
"&nbsp;";
      echo 
"</td>";
    }
    echo 
"<td align = center>";
    echo 
"<a href = \"mostrar_producto.php?sku=".$sku."\">".$product["title"]."</a> ";
    echo 
"</td>";
    echo 
"<td></td>";
    echo 
"<td align = left>Bs. ".number_format($product["price"], 2);
    echo 
"</td><td align = center>";
    
// if we allow changes, quantities are in text boxes
    
if ($change == true
        echo 
"<input type = text name = \"$sku\" value = $qty>";
    else 
    
//echo $qty;
      
echo "</td><td align = center>$".number_format($product["precio"]*$qty,2)."</td></tr>\n";
  }
   echo 
"<tr>
          <th colspan = "
. (2+$images) ." bgcolor=\"#D0E0F0\">&nbsp;</td>
          <th align = center bgcolor=\"#D0E0F0\">
              $items
          </th>
          <th align = center bgcolor=\"#D0E0F0\">
              Bs. "
.number_format($precio_total2).
          
"</th>
        </tr>"
;
   echo 
"<tr>
          <th colspan = "
. (2+$images) ." bgcolor=\"#ffffff\">&nbsp;</td>
          <th align = center bgcolor=\"#ffffff\">
             IVA
          </th>
          <th align = center bgcolor=\"#ffffff\">
              Bs. "
$iva= ($precio_total*12/100) ."</th>
        </tr>"
;
  
// display total row
  
echo "<tr>
          <th colspan = "
. (2+$images) ." bgcolor=\"#D0E0F0\">&nbsp;</td>
          <th align = center bgcolor=\"#D0E0F0\">
              Total
          </th>
          <th align = center bgcolor=\"#D0E0F0\">
              Bs. "
. ($precio_total $iva) ."
          </th>
        </tr>"
;
  
// display save change button
  
if($change == true)
  {
    echo 
"<tr>
            <td colspan = "
. (1+$images) .">&nbsp;</td>
            <td align = center>
              <input type = hidden name = save value = true>
              <input type = image src = \"images/save-changes.gif\"
                     border = 0 alt = \"Save Changes\">
            </td>
            <td>&nbsp;</td>
        </tr>"
;
  }
  echo 
"</form></table>";
}
?>
Por favor que estoy haciendo mal, no puedo verlo.... ????

Estuve analizando y tengo un problema aqui:

Código PHP:
<?
if($save)
  {
    foreach (
$cart as $sku => $qty)
    {
      if($
$sku=="0") {
        unset(
$cart[$sku]);
        }
      else {
        
$cart[$sku] = $$sku;
    }
    
$precio_total calculate_precio($cart);
    
$items calculate_items($cart);
  }
  }
?>
El valor de $save es true que viene de:

Código PHP:
<?
 
echo "<tr>
            <td colspan = "
. (1+$images) .">&nbsp;</td>
            <td align = center>
              <input type = hidden name = save value = true>
              <input type = image src = \"images/save-changes.gif\"
                     border = 0 alt = \"Save Changes\">
            </td>
            <td>&nbsp;</td>
        </tr>"
;
?>
El punto es que no me trae $cart[$sku].

Cómo puedo hacer para traerlo o si tienen alguna sugerencia para plantear el código de otra manera se los agradezco en el alma.

Última edición por GatorV; 05/05/2009 a las 11:30