Foros del Web » Programando para Internet » PHP »

carrito de compras

Estas en el tema de carrito de compras en el foro de PHP en Foros del Web. hola chicos llevo varios dias liado, soy novato, estoy siguiendo tutoriales para hacer una web , y me quede frenado en el carrito, tengo una ...
  #1 (permalink)  
Antiguo 14/12/2014, 13:29
 
Fecha de Ingreso: noviembre-2014
Mensajes: 60
Antigüedad: 9 años, 5 meses
Puntos: 0
carrito de compras

hola chicos llevo varios dias liado, soy novato, estoy siguiendo tutoriales para hacer una web , y me quede frenado en el carrito, tengo una una pagina que recoge los datos comprados, que hace la suma con el IVA , pero no se como llevarme esos datos, es decir, que pueda pagar mediante transferencia, opte por el boton paypal, pero no me sirve , no deja ponerle el precio que yo necesito en cada momento, tendria que por ejemplo recoger el total de la suma en otro archivo, con la cantidad a pagar y la confirmacion de pago, dejo aqui unos archivos a ver si sirven,

aqui es donde sale la opcion comprar

Código PHP:
Ver original
  1. <?php require_once('Connections/conexioncolegio.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.   if (PHP_VERSION < 6) {
  7.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.   }
  9.  
  10.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12.   switch ($theType) {
  13.     case "text":
  14.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15.       break;    
  16.     case "long":
  17.     case "int":
  18.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19.       break;
  20.     case "double":
  21.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22.       break;
  23.     case "date":
  24.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25.       break;
  26.     case "defined":
  27.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28.       break;
  29.   }
  30.   return $theValue;
  31. }
  32. }
  33.  
  34. $varProducto_DatosProducto = "0";
  35. if (isset($_GET["recordID"])) {
  36.   $varProducto_DatosProducto = $_GET["recordID"];
  37. }
  38. mysql_select_db($database_conexioncolegio, $conexioncolegio);
  39. $query_DatosProducto = sprintf("SELECT * FROM tblproductos WHERE tblproductos.isProducto = %s", GetSQLValueString($varProducto_DatosProducto, "int"));
  40. $DatosProducto = mysql_query($query_DatosProducto, $conexioncolegio) or die(mysql_error());
  41. $row_DatosProducto = mysql_fetch_assoc($DatosProducto);
  42. $totalRows_DatosProducto = mysql_num_rows($DatosProducto);
  43. ?>
  44.  
  45. <head>
  46.  
  47. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  48. <!-- InstanceBeginEditable name="doctitle" -->
  49. <title>La Cachemira</title>
  50. <!-- InstanceEndEditable -->
  51. <!-- InstanceBeginEditable name="head" -->
  52. <!-- InstanceEndEditable -->
  53. <link href="estilo/principal.css" rel="stylesheet" type="text/css" />
  54. <?php include("includes/header.php"); ?>
  55. </head>
  56.  
  57. <body>
  58. <?php include("includes/afterbody.php"); ?>
  59.  
  60. <div class="container">
  61.   <div class="header"><?php include("includes/cabecera.php"); ?></div>
  62.   <div class="sidebar1"><?php include("includes/menuizquierda.php"); ?>
  63.   </div>
  64.   <div class="content"><!-- InstanceBeginEditable name="Contenido" -->
  65.    
  66.   <h1><?php echo $row_DatosProducto['srtNombre']; ?></h1>
  67.   <!-- InstanceEndEditable -->
  68.     <p></p>
  69.    
  70.   <!-- InstanceBeginEditable name="titulo" --> <table width="100%" border="0" cellspacing="0" cellpadding="0">
  71.                   <tr>
  72.                     <td><img src="documentos/productos/<?php echo $row_DatosProducto['strImagen']; ?>" width="450" height="450" /></td>
  73.                     <td valign="top"><p><?php echo $row_DatosProducto['srtNombre']; ?></p>
  74.                     <p><?php echo $row_DatosProducto['dblPrecio']; ?></p>
  75.                     <?php if ((isset($_SESSION['MM_isUsuario']))  && ($_SESSION['MM_isUsuario']!=""))
  76.                     {?>
  77.                     <p><a href="carrito_add.php?recordID=<?php echo $row_DatosProducto['isProducto']; ?>">Comprar Producto</a></p>
  78.                     <?php }
  79.                     else
  80.                     {?>
  81.                     Necesitas <a href="usuario.php"><strong>darte de alta</strong></a> para comprar. Es gratuito.
  82. <?php }?></td>
  83.                   </tr>
  84.                   <tr>
  85.                     <td>&nbsp;</td>
  86.                     <td>&nbsp;</td>
  87.                   </tr>
  88.                 </table><!-- InstanceEndEditable --></div>
  89.   <div class="footer">
  90.     <?php include("includes/pie.php"); ?>
  91.   <!-- end .footer --></div>
  92.   <!-- end .container --></div>
  93. </body>
  94. <!-- InstanceEnd --></html>
  95. <?php
  96. mysql_free_result($DatosProducto);
  97. ?>

aqui me recoge el pedido y me ajusta la compra

Código PHP:
Ver original
  1. <?php require_once('Connections/conexioncolegio.php'); ?>
  2. <?php
  3.  
  4. if (!function_exists("GetSQLValueString")) {
  5. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  6. {
  7.   if (PHP_VERSION < 6) {
  8.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  9.   }
  10.  
  11.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  12.  
  13.   switch ($theType) {
  14.     case "text":
  15.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  16.       break;    
  17.     case "long":
  18.     case "int":
  19.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  20.       break;
  21.     case "double":
  22.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  23.       break;
  24.     case "date":
  25.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  26.       break;
  27.     case "defined":
  28.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  29.       break;
  30.   }
  31.   return $theValue;
  32. }
  33. }
  34.  $varUsuario_DatosCarrito = "0";
  35. if (isset($_SESSION["MM_isUsuario"])) {
  36.   $varUsuario_DatosCarrito = $_SESSION["MM_isUsuario"];
  37. }
  38. mysql_select_db($database_conexioncolegio, $conexioncolegio);
  39. $query_DatosCarrito = sprintf("SELECT * FROM tblcarrito WHERE tblcarrito.isUsuario = %s AND tblcarrito.intTransaccionEfectuada = 0", GetSQLValueString($varUsuario_DatosCarrito, "int"));
  40. $DatosCarrito = mysql_query($query_DatosCarrito, $conexioncolegio) or die(mysql_error());
  41. $row_DatosCarrito = mysql_fetch_assoc($DatosCarrito);
  42. $totalRows_DatosCarrito = mysql_num_rows($DatosCarrito);
  43. ?>
  44. <head>
  45.  
  46. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  47. <!-- InstanceBeginEditable name="doctitle" -->
  48. <title>La Cachemira</title>
  49. <!-- InstanceEndEditable -->
  50. <!-- InstanceBeginEditable name="head" -->
  51. <!-- InstanceEndEditable -->
  52. <link href="estilo/principal.css" rel="stylesheet" type="text/css" />
  53. <?php include("includes/header.php"); ?>
  54. </head>
  55.  
  56. <body>
  57. <?php include("includes/afterbody.php"); ?>
  58.  
  59. <div class="container">
  60.   <div class="header"><?php include("includes/cabecera.php"); ?></div>
  61.   <div class="sidebar1"><?php include("includes/menuizquierda.php"); ?>
  62.   </div>
  63.   <div class="content"><!-- InstanceBeginEditable name="Contenido" -->
  64.     <h1>Carrito de la Compra</h1>
  65.   <!-- InstanceEndEditable -->
  66.     <p></p>
  67.    
  68.   <table width="630" cellpadding="0" cellspacing="0">
  69.     <tr align="center">
  70.       <td width="178">Producto:</td>
  71.       <td colspan="3">Unidades:</td>
  72.       <td colspan="3">Precio:</td>
  73.       <td width="82">Acciones:</td>
  74.     </tr>
  75.      <?php $preciototal = 0;?>
  76.                   <?php do { ?>
  77.       <tr>
  78.         <td align="center"><?php echo ObtenerNombreProducto($row_DatosCarrito['isProducto']); ?></td>
  79.         <td colspan="3" align="center"><?php echo $row_DatosCarrito['intCantidad']; ?></td>
  80.          <td colspan="3" align="center"><?php echo ObtenerPrecioProducto($row_DatosCarrito['isProducto']); ?> Euros</td>
  81.         <td>Eliminar</td>
  82.          </tr>
  83.        <?php   $preciototal = $preciototal + ObtenerPrecioProducto($row_DatosCarrito['isProducto'])?>
  84.         <?php } while ($row_DatosCarrito = mysql_fetch_assoc($DatosCarrito)); ?>
  85.   </tr>
  86.     <tr>
  87.       <td>&nbsp;</td>
  88.      <td width="99" align="right" bgcolor="#FFFFB3" >Subtotal:&nbsp;</td>
  89.     <td width="60"  bgcolor="#FFFFB3"></td>
  90.     <td width="73" bgcolor="#FFFFB3" align="rigth"><?php echo $preciototal; ?> Euros</td>
  91.     <td width="69">&nbsp;</td>
  92.    
  93.     <td></td>
  94.   </tr>
  95.         <tr>
  96.           <td align="right" bgcolor="#FFFFB3">IVA:&nbsp;</td>
  97.           <td bgcolor="#FFFFB3" ></td>
  98.           <td bgcolor="#BBFFBB" align="center"><strong><?php echo ObtenerIVA(); ?>%</strong></td>
  99.         </tr>
  100.         <tr>
  101.           <td></td>
  102.           <td align="right"></td>
  103.           <td align="right"></td>
  104.           <td align="right" bgcolor="#FFFFB3">Valor del IVA:&nbsp;</td>
  105.           <td bgcolor="#FFFFB3"></td>
  106.           <td bgcolor="#FFFFB3" ><?php $multiplicador =  ObtenerIVA()/100;
  107.           $valordelIVA = $preciototal * $multiplicador;
  108.           echo $valordelIVA ;?>Euros</td>
  109.           <td>&nbsp;</td>
  110.           <td>&nbsp;</td>
  111.         </tr>
  112.         <tr>
  113.           <td>&nbsp;</td>
  114.           <td colspan="2" align="right"></td>
  115.           <td align="right" bgcolor="#FFFFB3">Total con iva:</td>
  116.           <td bgcolor="#FFFFB3"></td>
  117.           <td bgcolor="#FFFFB3"><?php
  118.           $multiplicador =  (100 + ObtenerIVA())/100;
  119.           $valorconIVA = $preciototal * $multiplicador;
  120.           echo $valorconIVA;?> Euros</td>
  121.           <td>&nbsp;</td>
  122.           <td>&nbsp;</td>
  123.         </tr>
  124.                 </table>
  125.                 <p>&nbsp;</p>
  126.                 <table width="279" cellpadding="0" cellspacing="0">
  127.   <tr>
  128.     <td width="76">&nbsp;</td>
  129.     <td width="201" class="pago" align="center"><a href="carrito_forma_pago.php"><strong>Seleccionar Forma de Pago</strong></a></td>
  130.   </tr>
  131. </table>
  132.  
  133.  </div>
  134.   <div class="footer">
  135.     <?php include("includes/pie.php"); ?>
  136.   <!-- end .footer --></div>
  137.   <!-- end .container --></div>
  138. </body>
  139. </html>
  140. <?php
  141. mysql_free_result($DatosCarrito);
  142. ?>
  #2 (permalink)  
Antiguo 14/12/2014, 13:31
 
Fecha de Ingreso: noviembre-2014
Mensajes: 60
Antigüedad: 9 años, 5 meses
Puntos: 0
Respuesta: carrito de compras

aqui la ultima aprte del codigo

Código PHP:
Ver original
  1. [B]aqui donde elige la forma de pago[/B]
  2.  
  3. [HIGHLIGHT="PHP"]<?php require_once('Connections/conexioncolegio.php'); ?>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6. <!-- InstanceBegin template="/Templates/Principal.dwt.php" codeOutsideHTMLIsLocked="false" -->
  7. <head>
  8. <link href='http://fonts.googleapis.com/css?family=Roboto+Condensed:400,300' rel='stylesheet' type='text/css'>
  9. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  10. <!-- InstanceBeginEditable name="doctitle" -->
  11. <title>La Cachemira</title>
  12. <!-- InstanceEndEditable -->
  13. <!-- InstanceBeginEditable name="head" -->
  14. <!-- InstanceEndEditable -->
  15. <link href="estilo/principal.css" rel="stylesheet" type="text/css" />
  16. <?php include("includes/header.php"); ?>
  17. </head>
  18.  
  19. <body>
  20. <?php include("includes/afterbody.php"); ?>
  21.  
  22. <div class="container">
  23.   <div class="header"><?php include("includes/cabecera.php"); ?></div>
  24.   <div class="sidebar1"><?php include("includes/menuizquierda.php"); ?>
  25.   </div>
  26.   <div class="content"><!-- InstanceBeginEditable name="Contenido" -->
  27.     <h1>&nbsp;Seleccionar Forma de Pago</h1>
  28.   <!-- InstanceEndEditable -->
  29.     <p></p>
  30.    
  31.   <!-- InstanceBeginEditable name="titulo" -->&nbsp;Elige la Forma de Pago
  32.    <form id="form1" name="form1" method="post" action="carrito_finalizacion.php">
  33.                   <p>
  34.                   <input name="radio" type="radio" id="radio" value="1" checked="CHECKED" />
  35.                   <label for="radio">PayPal</label><br />
  36.  <input type="radio" name="radio" id="radio" value="2" />
  37.                   <label for="radio">Transferencia</label>
  38.                   <br />
  39.  <input type="radio" name="radio" id="radio" value="3" />
  40.                   <label for="radio">VISA/Mastercard</label>
  41.       </p>
  42.                   <p>
  43.                     <input type="submit" name="button" id="button" class="boton" value="Pagar" />
  44.                   </p>
  45.                   <p>&nbsp;</p>
  46.     </form>
  47.                 <p>&nbsp;</p>
  48.   <!-- InstanceEndEditable --></div>
  49.   <div class="footer">
  50.     <?php include("includes/pie.php"); ?>
  51.   <!-- end .footer --></div>
  52.   <!-- end .container --></div>
  53. </body>
  54. <!-- InstanceEnd --></html>

y ahi me pierdo, no me aparece la cantidad a pagar, ademas si pagase con targeta no sabria como verlo, pues no hat manera de ver si hizo la transaccion, a ver si me ayudais por favor, gracias[/HIGHLIGHT]

Etiquetas: carrito, compras, html, mysql, select, sql
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:14.