11/01/2011, 07:39
|
| | Fecha de Ingreso: mayo-2008
Mensajes: 228
Antigüedad: 16 años Puntos: 2 | |
¿ Como paso unas variables de mi carrito hacia paypal ? ¿ Alguna ayuda de como enviar unas variables de forma conjunta al carrito de paypal ?. Tendria que enviar nombre del producto, codigo y precio total.
Si se compran mas de 2 cosas no se como enviarlo. Código PHP: <?PHP //ejemplo de llamada a la función de validación de productos // se incluye la función en fichero php externo include ("validar.php"); //tenemos que tener el código del producto de la tabla del carrito temporal //para ello leemos los productos del carrito temporal $db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or die ('Unable to connect. Check your connection parameters.'); mysql_select_db(MYSQL_DB, $db) or die(mysql_error($db)); $session = session_id(); $query = 'SELECT product_code, qty, session, precio FROM ecomm_temp_cart WHERE session = "' . $session . '" ORDER BY product_code ASC'; //realizamos la result del carrito temporal $result = mysql_query ($query, $db) or die ("Fallo en la result del carrito".mysql_error()); // Mostrar resultados de la result del carrito // si hay más de cero filas, llamamos a validar tantas veces como filas(productos) existan // si no hay filas se dará error $rows = mysql_num_rows ($result); if ($rows > 0) { for ($i=0; $i<$rows; $i++) { //lectura de fila $resultado = mysql_fetch_array ($result); // echo $resultado['product_code']; // echo $resultado['product_code']; // echo $resultado['product_code']; //llamada a función de validar para ver si el codigo de producto se encuentra en alguna de las 3 tablas. $existe1 = validar("productos_sin_dvd",$resultado['product_code'],$db); $existe2 = validar("dvd",$resultado['product_code'],$db); $existe3 = validar("novedades",$resultado['product_code'],$db); // print("</br>"); // echo $existe1; print("</br>"); // echo $existe2; print("</br>"); // echo $existe3; print("</br>"); $pieces1 = explode("@", $existe1); $pieces2 = explode("@", $existe2); $pieces3 = explode("@", $existe3); //echo $pieces[0]; // piece1 //echo $pieces[1]; // piece2 if ($pieces1[0] == 'si'){ $preciov[$i] = $pieces1[2]; $nombrev[$i] = $pieces1[1]; }else if ($pieces2[0] == 'si'){ $preciov[$i] = $pieces2[2]; $nombrev[$i] = $pieces2[1]; }else if ($pieces3[0] == 'si'){ $preciov[$i] = $pieces3[2]; $nombrev[$i] = $pieces3[1]; } if ($pieces1[0]== 'no' && $pieces2[0] =='no' && $pieces3[0]=='no') { //esto determina que el producto no //existe en ninguna de las tres tablas print ("<strong>El producto ".$resultado['product_code']." no existe en las tablas</strong>\n"); } } } else { // no hay filas en el carrito // aquí se retorna el error de que no hay filas en el carrito print("<strong> No hay datos en el carrito \n"); } $result = mysql_query ($query, $db) or die ("Fallo en la result del carrito".mysql_error()); // Mostrar resultados de la result del carrito // si hay más de cero filas, llamamos a validar tantas veces como filas(productos) existan // si no hay filas se dará error $rows = mysql_num_rows ($result); if ($rows == 1) { echo ' <p> Actualmente tiene 1 producto en su carrito. </p>'; } else { echo ' <p> Actualmente tiene ' . $rows . ' productos en su carrito. </p> '; } if ($rows > 0) { ?> <?php } ?> <hr/> </td> </tr> </table> <div id="contenedorpagos" style="width:1649px;"> <div style="float:left"> <form method="post" action="ecomm_checkout3.php"> <input type="submit" name="submit" value="PAGAR CON TARJETA"/> <input type="hidden" name="last_name" value=" <?php echo htmlspecialchars($_POST['first_name']);?> "/> <input type="hidden" name="first_name" value=" <?php echo htmlspecialchars($_POST['last_name']);?> "/> <input type="hidden" name="address_1" value=" <?php echo htmlspecialchars($_POST['address_1']);?> "/> <input type="hidden" name="address_2" value=" <?php echo htmlspecialchars($_POST['address_2']);?> "/> <input type="hidden" name="city" value=" <?php echo htmlspecialchars($_POST['city']);?> "/> <input type="hidden" name="state" value=" <?php echo htmlspecialchars($_POST['state']);?> "/> <input type="hidden" name="zip_code" value=" <?php echo htmlspecialchars($_POST['zip_code']);?> "/> <input type="hidden" name="phone" value=" <?php echo htmlspecialchars($_POST['phone']);?> "/> <input type="hidden" name="email" value=" <?php echo htmlspecialchars($_POST['email']);?> "/> <input type="hidden" name="shipping_first_name" value=" <?php echo htmlspecialchars($_POST['shipping_first_name']);?> "/> <input type="hidden" name="shipping_last_name" value=" <?php echo htmlspecialchars($_POST['shipping_last_name']);?> "/> <input type="hidden" name="shipping_address_1" value=" <?php echo htmlspecialchars($_POST['shipping_address_1']);?> "/> <input type="hidden" name="shipping_address_2" value=" <?php echo htmlspecialchars($_POST['shipping_address_2']);?> "/> <input type="hidden" name="shipping_city" value=" <?php echo htmlspecialchars($_POST['shipping_city']);?> "/> <input type="hidden" name="shipping_state" value=" <?php echo htmlspecialchars($_POST['shipping_state']);?> "/> <input type="hidden" name="shipping_zip_code" value=" <?php echo htmlspecialchars($_POST['shipping_zip_code']);?> "/> <input type="hidden" name="shipping_phone" value=" <?php echo htmlspecialchars($_POST['shipping_phone']);?> "/> <input type="hidden" name="shipping_email" value=" <?php echo htmlspecialchars($_POST['shipping_email']);?> "/> <input type="hidden" name="order_id" value=" <?php echo htmlspecialchars($_POST['order_id']);?> "/> </form> </div> <div style="float:left; margin-left:10px;"> <!--<input name='cmd' type='hidden' value='_cart'/> <input type='hidden' name='upload' value='1'> <input type='hidden' name='business' value='[email protected]'> <input type='hidden' name='currency_code' value='EUR'> <input name='item_name_1' type='hidden' value='Producto1' /> <input name='amount_1' type='hidden' value='2.50' /> <input name='item_name_3' type='hidden' value='Producto3' /> <input name='amount_3' type='hidden' value='9.99' /> <input name='item_name_4' type='hidden' value='Producto4' /> <input name='amount_4' type='hidden' value='9.99' /> <input type='submit' value='Comprar ahora'> </form><br><br><a href='shop.php'>Seguir Comprando</a> --> </div> <div style="float:left; margin-left:10px;"> <FORM action='http://www.imagen4d.com' method='POST'> <input type="hidden" name="order" value="<?php order_id ?>"> <input type="hidden" name="store" value="PI00016049"> <input type="hidden" name="idioma" value="es"> <INPUT TYPE="SUBMIT" value=" CONTRAREEMBOLSO "> </FORM> </div> </div> <br /> <div style="margin-top:25px;"> <table style="width: 100%;"> <tr> <th style="width: 100px;"> </th > <th>Nombre del articulo </th> <th> Cantidad </th> <th> Precio por articulo </th> <th> Precio total </th> </tr> <?php $total = 0; $c=0; $odd = true; while ($row = mysql_fetch_array($result)) { extract($row); ?> <td style="text-align:center;"><img src="http://www.grutinet.com/articulos/or/or_<?php echo $product_code;?>.jpg" alt=" <?php echo $nombrev[$c]; ?> " width="50px;"/> </td> <td><?php echo $nombrev[$c]; ?> </td> <td><div> <?php echo $qty; ?> </div></td> <td style="text-align: right;">€ <?php echo $preciov[$c]; ?> </td> <td style="text-align: right;">€ <?php echo number_format($preciov[$c] * $qty, 2); ?> </td> </tr> <?php $total = $total + $preciov[$c] * $qty; $c++; } ?> </table> <p> Total del pedido <strong><?php echo number_format($total, 2); ?>€ </strong> </p> </div> |