Ver Mensaje Individual
  #5 (permalink)  
Antiguo 23/02/2015, 08:44
marcelourbinagomez
 
Fecha de Ingreso: febrero-2015
Mensajes: 16
Antigüedad: 9 años, 2 meses
Puntos: 0
Respuesta: Agregar producto al carro sin estar registrado

Código PHP:
Ver original
  1. <?php
  2. require('db/db1.php');
  3. require_once('secure_novalidate.php');
  4.  
  5. if (isset($_SESSION["id"])) {
  6.  
  7.     $rec_usu = "Select * from usuarios where id_usr = '" . $_SESSION["id"] . "'";
  8.     $res_usu = $db1->Execute($rec_usu) or die($db1->ErrorMsg());
  9.    
  10. } else {
  11.     $_SESSION["id"]=0;
  12. }
  13.  
  14. $query_producto = "select * from productos where est_pro = 1 order by id_pro";
  15. $res_producto = $db1->Execute($query_producto) or die($db1->ErrorMsg());
  16.  
  17.  
  18.  
  19. $total_producto = $res_producto->RecordCount();
  20. $filas_producto = $total_producto/3;
  21.  
  22. $_SESSION['ElementosCarro'] = "0";
  23.  
  24.  
  25. if (isset($_REQUEST['id_producto'])) {
  26.     $id_producto = $_REQUEST['id_producto'];
  27. } else {
  28.     $id_producto = 0;
  29. }
  30.  
  31.  
  32.  
  33. ?>
  34.                        
  35.                 <?php
  36.                     while(!$res_producto->EOF){
  37.                         $imagen = "images/".$res_producto->Fields("img_prod");
  38.                         $imagen_alter ="img/productos/no.png" ;
  39.                                 //if($res_producto->Fields("tipo_prod")=="producto" || $_SESSION["id"] != 0){
  40.                                 if($res_producto->Fields("tipo_prod")=="producto") /* $res_producto->Fields("tipo_prod")=="bolsa"*/{
  41.                                    
  42.                                     echo('<li id="producto">');
  43.                                     if (file_exists($imagen)&&strlen($res_producto->Fields("img_prod"))>1) {
  44.                                         echo('<a class="cbp-vm-image" href="#"><img src="' . $imagen . '"></a>');
  45.                                     } else {
  46.                                         echo('<a class="cbp-vm-image" href="#"><img src="' . $imagen_alter . '"></a>');
  47.                                     }              
  48.                                    
  49.                                     echo('<div class="cbp-vm-price">$ ' . number_format(floatval($res_producto->Fields("prec_pro")), 0, ',', '.') . '</div>');
  50.                                     echo('<div class="cbp-vm-details">');
  51.                                                     echo($res_producto->Fields("desc_pro"));
  52.                                     echo('</div>');
  53.                       echo('<div id="ok' . $res_producto->Fields("id_pro") . '" class="cbp-vm-add-ok"><img src="images/ok.png" width="27"><h3>Agregado</h3><br><p><a href="carro.php">Ver carro</a></p></div>');
  54.                                     echo('<button id="add' . $res_producto->Fields("id_pro") . '"  class="amarillo">Agregar al carro</button>');
  55.                    
  56.                                     echo('</li>');
  57.                                 }
  58.                             $res_producto->MoveNext();
  59.                             }
  60.                             ?>
  61.                        
  62.  
  63.  
  64. <script type="text/javascript" src="js/jquery.min.js"></script>
  65. <script type="text/javascript" src="js/jquery.easing.1.3.js"></script>
  66.  
  67.          
  68.         <script src="js/classie.js"></script>
  69.         <script src="js/modalEffects.js"></script>
  70.  
  71.         <!-- for the blur effect -->
  72.         <!-- by @derSchepp https://github.com/Schepp/CSS-Filters-Polyfill -->
  73.         <script>
  74.             // this is important for IEs
  75.             var polyfilter_scriptpath = '/js/';
  76.         </script>
  77.         <script src="js/cssParser.js"></script>
  78.         <script src="js/css-filters-polyfill.js"></script>
  79.        
  80.         <script src="js/cbpViewModeSwitch.js"></script>
  81.         <script src="js/jquery.scrollTo.min.js"></script>
  82.        
  83.        
  84.         <script>
  85.        
  86.     $(document).ready(function(){
  87.            
  88.             <?php
  89.            
  90.                 if ($id_producto!="") {
  91.                     echo('$.ajax({');
  92.                    
  93.                     echo('}).done(function(data) {');      
  94.                     echo('$("#ok' . $id_producto . '").show("slow");');
  95.                     echo('$("#add' . $id_producto . '").hide();');                                 
  96.                     echo('});');           
  97.                 }
  98.                 $query_producto = "select * from productos where est_pro = 1";
  99.                 $res_producto = $db1->Execute($query_producto) or die($db1->ErrorMsg());
  100.                                
  101.                 while(!$res_producto->EOF) {
  102.            
  103.                     echo('$("#add' . $res_producto->Fields('id_pro') . '").click(function(){');
  104.                     if($res_producto->Fields("tipo_prod")=="producto" || $_SESSION["id"] != 0){
  105.                        
  106.                        
  107.                         echo('$.ajax({');
  108.                        
  109.                         echo('}).done(function(data) {');      
  110.                         echo('$("#ok' . $res_producto->Fields('id_pro') . '").show("slow");');
  111.                         echo('$("#add' . $res_producto->Fields('id_pro') . '").hide();');                                  
  112.                         echo('});');
  113.                     } else {
  114.                         echo('$("#need-user").delay(1000).fadeIn(400, function(){');
  115.                         echo("$('#need-user-content').slideDown( 500, 'easeOutBounce');");
  116.                         echo('});');       
  117.                        
  118.                       echo('$("#cerrar-need-user").click(function (){');
  119.                         echo('$("#need-user").hide(100);');
  120.                         echo('});');
  121.                        
  122.                         echo('$("#Action").attr("action", "procesos/login_usuario
  123.                         ?id_producto=' . $res_producto->Fields('id_pro') . '");');
  124.                        
  125.                     }
  126.                    
  127.                 $elementos_carro = $_SESSION['ElementosCarro'];
  128.                     if ($elementos_carro=='') {
  129.                         $elementos_carro='0';
  130.                     }
  131.                    
  132.                     $elementos_carro = $elementos_carro + 1;
  133.                     $_SESSION['ElementosCarro'] = $elementos_carro;
  134.                     $_SESSION['Carro_' . $elementos_carro] = $res_producto->Fields('id_pro');
  135.                                
  136.                
  137.                 echo('});');
  138.                 $res_producto->MoveNext();
  139.             }
  140.           ?>
  141.            
  142.            
  143.        });
  144.        
  145.        
  146.        
  147.         </script>
  148.  
  149. <script>
  150.   (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  151.   (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  152.   m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  153.   })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  154.  
  155.   ga('create', 'UA-48658134-1', 'finderbee.com');
  156.   ga('send', 'pageview');
  157.  
  158. </script>
  159.  
  160. <?php include "footer.php"; ?>